123456789101112131415161718192021222324252627282930313233 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
- @AUTHOR: ASJRD018
- @NAME: AnsjerFormal
- @software: PyCharm
- @DATE: 2019/3/7 10:50
- @Version: python3.6
- @MODIFY DECORD:ansjer dev
- @file: gcmm.py
- @Contact: chanjunkai@163.com
- """
- from gcm import GCM
- API_KEY = 'AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I'
- gcm = GCM(API_KEY)
- data = {'param1': 'value1', 'param2': 'value2'}
- # Downstream message using JSON request
- reg_ids = ['eSooD4fAARg:APA91bEPenBPnSn5aXIQk56QdLOQ1Mu3hevHsekP_0eDpg458y2ZMBP6By2rVsGYIoxZrXxvkkptPKUE9CmUygBxaZXABddUWB9FyLlznRFerC7RG9X5PsEOH58xK9_aTUdkT7p6Ocld']
- response = gcm.json_request(registration_ids=reg_ids, data=data)
- # Downstream message using JSON request with extra arguments
- res = gcm.json_request(
- registration_ids=reg_ids, data=data,
- collapse_key='uptoyou', delay_while_idle=True, time_to_live=3600
- )
- # Topic Messaging
- topic = 'topic name'
- res = gcm.send_topic_message(topic=topic, data=data)
- print(res)
|