使用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)