def sendEhelp(account, mess): push = xinge.XingeApp(access_id, secret_key) ret = push.PushSingleAccount(0, account, mess) if ret[0] == 0: return True print ret[0] return False
def customedPush(msg): xios = xinge.XingeApp(2200050216, '2f7f56e61191393d6b25079ee9d839b0') ios = xinge.MessageIOS() ios.alert = msg ios.sound = "default" ios.badge = 1 ios.expireTime = 86400 ret = xios.PushAllDevices(0, ios, 1) xandroid = xinge.XingeApp(2100081128, 'db2f948d8f2b962fc4e1cb4a26f7d87d') android = xinge.Message() android.type = xinge.Message.TYPE_NOTIFICATION android.title = '快乐居家' android.content = msg android.expireTime = 86400 res = xandroid.PushAllDevices(0, android) if ret[0] == 0 and res[0] == 0: return True else: return False
def DemoQueryTokenTags(x): # 请把这里示例token修改为你的真实token ret = x.QueryTokenTags('token00000000000000000000000000000000001') print ret # 查询标签绑定的设备数 def DemoQueryTagTokenNum(x): # 请把这里示例tag修改为你的真实tag ret = x.QueryTagTokenNum('tag1') print ret if '__main__' == __name__: # 初始化app对象,设置有效的access id和secret key x = xinge.XingeApp(0, 'secret') # 构建一条消息,可以是通知或者透传消息 #msg = BuildMsg() msg = BuildNotification() # 构建iOS消息。注意iOS只有一种消息类型,不分通知/透传 # iOS推送,调用push接口时切记设置ENV #msg = BuildIOSMsg() DemoPushToken(x, msg) DemoPushAccount(x, msg) DemoPushAccountList(x, msg) DemoPushAll(x, msg) DemoPushTags(x, msg) DemoQueryPushStatus(x)
DB_XIAOXIN = { 'host': '192.168.1.12', 'port': 3306, 'user': '******', 'passwd': 'aiP4j2rWSQuZkwA', 'db': 'test_xiaoxin' } conn = MySQLdb.Connect(host=DB_XIAOXIN['host'], port=DB_XIAOXIN['port'], user=DB_XIAOXIN['user'], passwd=DB_XIAOXIN['passwd'], db=DB_XIAOXIN['db'], charset='utf8') conn.autocommit(True) mylock = threading.RLock() android_xg = xinge.XingeApp(2100062823, 'db25ca72df75ca7b436001b8db9538bb') ios_xg = xinge.XingeApp(2200062766, 'c9206fa64a4cb03ed712c1ea4f23ffb1') def logger(e, ty=''): datestr = time.strftime('%Y%m%d', time.localtime(time.time())) filename = 'py_' + ty + '_' + datestr + '.log' if not os.path.exists(filename): try: f = open(filename, "w") f.close() except: filename = 'py.log' logger = logging.getLogger() #set loghandler file = logging.FileHandler(filename)
''' import sys import xinge mess = xinge.Message() #mess = MessageIOS() mess.type = xinge.Message.TYPE_NOTIFICATION mess.title = sys.argv[2] mess.content = sys.argv[3] mess.multiPkg = 1 #含义:样式编号0,响铃,震动,不可从通知栏清除 #mess.style = Style(0,1,1,0) #action = ClickAction() #action.actionType = ClickAction::TYPE_URL #action.url = "http://xg.qq.com" #mess.action = $action #mess.custom = {'key1':'value1', 'key2':'value2'} #t1 = TimeInterval(12, 0, 13, 59) #t2 = TimeInterval(19, 0, 20, 59) #mess.acceptTime = (t1, t2) push = xinge.XingeApp(2100145241, '37c1e7cb4edf243e2a5279315310dd04') #完善Message 消息 #PushSingleDevice(deviceToken, message, environment=0) ret = push.PushSingleDevice(sys.argv[1], mess) #ret = push.PushSingleDevice("56dbb72c6ac5bb7540d59ff1337d65d415652bb6", mess) print ret