当前位置: 首页>>代码示例>>Python>>正文


Python Channel.getRequestId方法代码示例

本文整理汇总了Python中Channel.getRequestId方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.getRequestId方法的具体用法?Python Channel.getRequestId怎么用?Python Channel.getRequestId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Channel的用法示例。


在下文中一共展示了Channel.getRequestId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Channel

# 需要导入模块: import Channel [as 别名]
# 或者: from Channel import getRequestId [as 别名]
import time
sys.path.append("..")
from Channel import *

channel_id = 'your_channel_id' #android
msg = '{"title":"Message from Push","description":"hello world"}'
#msg_ios = '{"aps":{"alert":"iOS Message from Push","sound":"","badge":1},"key1":"value1","key2":"value2"}'
opts = {'msg_type':1, 'expires':300} 

c = Channel()

try:
    ret = c.pushMsgToSingleDevice(channel_id, msg, opts)
    print('ret: ', end=' ')
    print(ret)
    print(c.getRequestId())
except ChannelException as e:
    print('[code]', end=' ')
    print(e.getLastErrorCode())
    print('[msg]', end=' ')
    print(e.getLastErrorMsg())
    print('[request id]', end=' ')
    print(c.getRequestId())

try:
    ret = c.pushMsgToAll(msg, opts)
    print('ret: ', end=' ')
    print(ret)
    print(c.getRequestId())
except ChannelException as e:
    print('[code]', end=' ')
开发者ID:daihaovigg,项目名称:BaiduYunPushServiceSdk,代码行数:33,代码来源:sample.py

示例2: Channel

# 需要导入模块: import Channel [as 别名]
# 或者: from Channel import getRequestId [as 别名]
import time
sys.path.append("..")
from Channel import *

channel_id = 'your_channel_id' #android
msg = '{"title":"Message from Push","description":"hello world"}'
#msg_ios = '{"aps":{"alert":"iOS Message from Push","sound":"","badge":1},"key1":"value1","key2":"value2"}'
opts = {'msg_type':1, 'expires':300} 

c = Channel()

try:
    ret = c.pushMsgToSingleDevice(channel_id, msg, opts)
    print 'ret: ',
    print ret
    print c.getRequestId()
except ChannelException as e:
    print '[code]',
    print e.getLastErrorCode()
    print '[msg]',
    print e.getLastErrorMsg()
    print '[request id]',
    print c.getRequestId()

try:
    ret = c.pushMsgToAll(msg, opts)
    print 'ret: ',
    print ret
    print c.getRequestId()
except ChannelException as e:
    print '[code]',
开发者ID:zhangzhiwei1228,项目名称:zzw_rendan,代码行数:33,代码来源:sample.py


注:本文中的Channel.getRequestId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。