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)
  • 相关阅读:
    Qt 去除控件边框线
    Qt 自定义可编辑 模型视图
    Qt double类型输出问题
    vue实例
    初识vue
    python中的数据类型
    python 列表解析式
    Goland常用快键键 mac pro
    文档对象模型DOM
    正则表达式
  • 原文地址:https://www.cnblogs.com/yeyong/p/4598245.html
Copyright © 2011-2022 走看看