与yandex appmetrica集成的api
appmetrica的Python项目详细描述
与yandex appmetrica集成的应用程序https://appmetrica.yandex.ru/
yandex文档https://tech.yandex.ru/appmetrica/doc/mobile-api/push/use-cases-docpage/
在使用API之前,必须:
- 从appmetrica.yandex.ru中的帐户获取应用程序ID
- [生成访问令牌](https://tech.yandex.ru/appmetrica/doc/mobile-api/intro/authorization-docpage/)
发送按键
创建api实例:
from appmetrica.push.api import PushAPI api = PushAPI(application_id, access_token)
创建组以合并报表中的发送:
group_id = api.create_group('test-push-1')
通过组id,设备列表和消息发送推送方法和调用:
from appmetrica.push.api import TokenTypes transfer_id = api.send_push(group_id, devices=devices, ios_message=ios_message, android_message=android_message, tag='harry potter') devices - list of token objects like: [ { "id_type": TokenTypes.APPMETRICA_DEVICE_ID, "id_values": ["123456789", "42"] }, { "id_type": TokenTypes.IOS_IFA, "id_values": ["8A690667-6204-4A6A-9B38-85DE016....."] }, { "id_type": TokenTypes.ANDROID_PUSH_TOKEN, "id_values": ["eFfxdO7uCMw:APA91bF1tN3X3BAbiJXsQhk-..."] } ] ios_message - push message for ios devices android_message - push message for android devices: { "silent": false, "content": { "title": "string", "text": "string", "sound": "disable", "data": "string" } }
检查push call的状态check_status方法:
status = api.check_status(transfer_id)
可用组列表
创建api实例:
from appmetrica.push.api import PushAPI api = PushAPI(application_id, access_token)
获取组列表
group_id = api.get_groups()
导出令牌
创建api实例:
from appmetrica.export.api import ExportAPI api = ExportAPI(application_id, access_token)
使用必需的字段调用push_tokens方法:
data = api.export_push_tokens('token', 'ios_ifa', 'google_aid')
导出设备
创建api实例:
from appmetrica.export.api import ExportAPI api = ExportAPI(application_id, access_token)
使用必需的字段调用push_tokens方法:
date_till = datetime.now() date_from = date_till - timedelta(days=7) data = api.export_installations('ios_ifv', date_from=date_from, date_till=date_till)
在pypi上发布发布
全局安装twine:
pip install twine
别忘了提高软件包版本:
__version__ = '1.0.2'
生成版本:
python setup.py sdist
在pypi上发布发布:
twine upload dist/litresapi-1.0.1.tar.gz
更改日志
1.0.2(2019-01-09)
- 将请求超时时间增加到30秒
1.0.1(2018-12-17)
- 替换不推荐的发送方法
1.0.0(2017-12-14)
- 初始版本