zoukankan      html  css  js  c++  java
  • python 调用jpush推送消息

    使用jpush的python方式, 做为邮件,短信之后的另一种提醒方式,同时还有微信方式可以研究下

    # coding=utf-8
    import jpush
    
    
    def push_msg(message,device_id):
        app_key = 'app_key'
        master_secret = 'master_key'
    
        _jpush = jpush.JPush(app_key, master_secret)
        push = _jpush.create_push()
        # push.audience = jpush.audience([{"registration_id":device_id}])
        push.audience = {'registration_id': [device_id]}
        # push.audience = device_id
        msg = jpush.android(
                            message,
                            None,
                            None,
                            {
                                "sn": message,      # 强行套用app中notification的相关格式
                                "type": "T4",
                                "url": "http://www.baidu.com"
                            }
                            )
        push.notification = jpush.notification("hello jpush", None, msg, None) # 第一个值似乎没有什么用,另外这个push目前只发送至android
        # push.options = {"time_to_live": 86400, "sendno": 12345, "apns_production":True}
        push.options = {"time_to_live": 86400, "apns_production": True}
        push.platform = jpush.platform("android")
        push.send()
    
    if __name__=="__main__":
        device_id = '001023123123'  # device_id 需要事先获得
        message = "This is a test"
        push_msg(message,device_id)
  • 相关阅读:
    word2vec模型评估方案
    分词问题整理和发现
    11.1第一次相似度算法测试结果
    如何使用向量代表文档doc或者句子sentence
    fasttext学习笔记
    传统变量抽样
    统计抽样与非统计抽样
    误受风险和误拒风险
    企业所得税怎么算
    进一步审计程序
  • 原文地址:https://www.cnblogs.com/yeyong/p/4598245.html
Copyright © 2011-2022 走看看