Ejemplo n.º 1
0
def pushMsgToSingle_dispatch(receiver, action, meta, data):
    '''
    push message uploaded from sender to receiver
    sender and receiver are User objects,
    message is string
    '''
    def makeMessage_generic(receiver, action, meta, data):
        msg_body = {
            'action': action,
            'meta': meta,
            'data': data,
        }
        return json.dumps(msg_body)


    push = IGeTui(HOST, APPKEY, MASTERSECRET)
    trasmission_data = TransmissionTemplate()
    trasmission_data.transmissionType = 1
    trasmission_data.appId = APPID
    trasmission_data.appKey = APPKEY
    trasmission_data.transmissionContent = makeMessage_generic(receiver, action, meta, data)
    trasmission_data.setPushInfo("", 2, "", "", "", "", "", "", 1)

    igt_message = IGtSingleMessage()
    igt_message.isOffline = True
    igt_message.offlineExpireTime = 1000 * 3600 * 12
    igt_message.data = trasmission_data
    igt_message.pushNetWorkType = 2

    igt_target = Target()
    igt_target.appId = APPID
    igt_target.clientId = receiver.cid

    ret = push.pushMessageToSingle(igt_message, igt_target)
    return ret
Ejemplo n.º 2
0
def pushMsgToSingle(sender, receiver, message):
    '''
    push message uploaded from sender to receiver
    sender and receiver are User objects,
    message is string
    '''
    push = IGeTui(HOST, APPKEY, MASTERSECRET)
    trasmission_data = TransmissionTemplate()
    trasmission_data.transmissionType = 1
    trasmission_data.appId = APPID
    trasmission_data.appKey = APPKEY
    trasmission_data.transmissionContent = makeMessage(sender, receiver, message)
    trasmission_data.setPushInfo("", 2, "", "", "", "", "", 1)

    igt_message = IGtSingleMessage()
    igt_message.isOffline = True
    igt_message.offlineExpireTime = 1000 * 3600 * 12
    igt_message.data = trasmission_data
    igt_message.pushNetWorkType = 2

    igt_target = Target()
    igt_target.appId = APPID
    igt_target.clientId = receiver.cid

    ret = push.pushMessageToSingle(igt_message, igt_target)
    return ret
Ejemplo n.º 3
0
def pushMessageToApp():
    push = IGeTui(HOST, APPKEY, MASTERSECRET)

    # 新建一个推送模版, 以链接模板为例子,就是说在通知栏显示一条含图标、标题等的通知,用户点击可打开您指定的网页
    template = LinkTemplate()
    template.appId = APPID
    template.appKey = APPKEY
    template.title = u"欢迎使用个推!"
    template.text = u"这是一条推送消息~"
    template.logo = ""
    template.url = "http://www.baidu.com"
    template.transmissionType = 1
    template.transmissionContent = ''
    template.isRing = True
    template.isVibrate = True
    template.isClearable = True

    #定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
    message = IGtAppMessage()
    message.data = template
    message.isOffline = True
    message.offlineExpireTime = 1000 * 600
    message.appIdList.extend([APPID])

    ret = push.pushMessageToApp(message)
    print ret
Ejemplo n.º 4
0
def pushGetuiMessageToApp(content, title, text):
    push = IGeTui(getuiHost, getuiAppKey, getuiMasterSecret)

    template = NotificationTemplateDemo(content, title, text)

    message = IGtAppMessage()
    message.data = template
    message.isOffline = True
    message.offlineExpireTime = 1000 * 3600 * 12
    message.appIdList.extend([getuiAppId])

    ret = push.pushMessageToApp(message, 'toApp')
    print ret
Ejemplo n.º 5
0
def pushMessageToSingle2():
    if GetuiPush.push is None:
        GetuiPush.push = IGeTui(HOST, APPKEY, MASTERSECRET)
    push = GetuiPush.push
    # push = IGeTui(HOST, APPKEY, MASTERSECRET)
    # push = IGeTui("",APPKEY,MASTERSECRET)#此方式可通过获取服务端地址列表判断最快域名后进行消息推送,每10分钟检查一次最快域名
    # 消息模版:
    # TransmissionTemplate:透传功能模板,定义透传内容,应用启动形式
    template = TransmissionTemplateDemo()
    # 定义"SingleMessage"消息体,设置是否离线,离线有效时间,模板设置
    message = IGtSingleMessage()
    message.isOffline = True
    message.offlineExpireTime = 1000 * 3600 * 12
    message.data = template
    message.pushNetWorkType = 0  # 设置是否根据WIFI推送消息,2为4G/3G/2G,1为wifi推送,0为不限制推送
    target = Target()
    target.appId = APPID
    target.clientId = CID
    # target.alias = ALIAS

    try:
        ret = push.pushMessageToSingle(message, target)
        print ret
    except RequestException, e:
        # 发生异常重新发送
        requstId = e.getRequestId()
        ret = push.pushMessageToSingle(message, target, requstId)
        print ret
Ejemplo n.º 6
0
def pushGetuiMessageToSingle(cid, content, title, text):
    push = IGeTui(getuiHost, getuiAppKey, getuiMasterSecret)

    template = NotificationTemplateDemo(content, title, text)

    message = IGtSingleMessage()
    message.isOffline = True
    message.offlineExpireTime = 1000 * 3600 * 12
    message.data = template
    message.pushNetWorkType = 1

    target = Target()
    target.appId = getuiAppId
    target.clientId = cid

    ret = push.pushMessageToSingle(message, target)
    print ret
Ejemplo n.º 7
0
def push_Android(text):
	push = IGeTui(HOST, APPKEY, MASTERSECRET)
	template = NotificationTemplate()
	#1:click to open,2:click to nothing
	template.transmissionType = 1
	template.appId = APPID
	template.appKey = APPKEY
	template.transmissionContent = text
	template.title = "Notifier"
	template.text = text
	message = IGtAppMessage()
	message.data = template
	message.isOffline = True
	message.offlineExpireTime = 1000 * 3600 * 12
	message.appIdList.extend([APPID])
	ret = push.pushMessageToApp(message)
	print(ret)
Ejemplo n.º 8
0
def pushMessageToApp(title, href):
    push = IGeTui(config.HOST, config.APPKEY, config.MASTERSECRET)
    template = temp.igt_link_template.LinkTemplate()
    template.appId = config.APPID
    template.appKey = config.APPKEY
    template.title = 'XSS:%s' % title
    template.text = "href:%s" % href
    template.logo = ""
    template.url = "http://112.74.204.232:8080/xssindex"
    template.transmissionType = 1
    template.transmissionContent = ''
    template.isRing = True
    template.isVibrate = True
    template.isClearable = True
    message = IGtAppMessage()
    message.data = template
    message.isOffline = True
    message.offlineExpireTime = 1000 * 600
    message.appIdList.extend([config.APPID])
    ret = push.pushMessageToApp(message)
Ejemplo n.º 9
0
def pushGetuiMessageToList(cidList, content, title, text):
    push = IGeTui(getuiHost, getuiAppKey, getuiMasterSecret)

    template = NotificationTemplateDemo(content, title, text)

    message = IGtListMessage()
    message.data = template
    message.isOffline = True
    message.offlineExpireTime = 1000 * 3600 * 12
    message.pushNetWorkType = 0

    arr = []

    for cid in cidList.split(','):
        target = Target()
        target.appId = getuiAppId
        target.clientId = cid
        arr.append(target)

    contentId = push.getContentId(message, 'ToList')
    ret = push.pushMessageToList(contentId, arr)
    print ret
Ejemplo n.º 10
0
from igetui.igt_message import IGtAppMessage
from igetui.template.igt_notification_template import NotificationTemplate
from igt_push import IGeTui
import requests
import time
import json

APPID = 'xx4YtJHqfC6rezkYndlzD5'
APPKEY = 'xHyHtP3sjpAYuaf4YntShA'
MASTERSECRET = 'XYo36KsDWg9Ie9pPI6YRi7'
CID = 'e560b884d8d9bf5bc5a0f9da545a11f3'
HOST = 'http://sdk.open.api.igexin.com/apiex.htm'

#定义常量, appId、appKey、masterSecret 采用本文档 "第二步 获取访问凭证 "中获得的应用配置

push = IGeTui(HOST, APPKEY, MASTERSECRET)

# 新建一个推送模版, 以链接模板为例子,就是说在通知栏显示一条含图标、标题等的通知,用户点击可打开您指定的网页
template = NotificationTemplate()
template.appId = APPID
template.appKey = APPKEY
template.logo = ""
template.url = ""
template.transmissionType = 1
template.transmissionContent = ''
template.isRing = True
template.isVibrate = True
template.isClearable = True

#定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
message = IGtAppMessage()
Ejemplo n.º 11
0
def pushMessageToSingle():
    # http的接口
    # push = IGeTui(None, APPKEY, MASTERSECRET,False)
    # https的接口
    # push = IGeTui(None, APPKEY, MASTERSECRET,True)
    # 根据HOST区分是https还是http
    push = IGeTui(HOST, APPKEY, MASTERSECRET)
    # 消息模版:
    # 1.TransmissionTemplate:透传功能模板
    # 2.LinkTemplate:通知打开链接功能模板
    # 3.NotificationTemplate:通知透传功能模板
    # 4.NotyPopLoadTemplate:通知弹框下载功能模板

    #     template = NotificationTemplateDemo()
    # template = LinkTemplateDemo()
    # 新建一个推送模版, 以链接模板为例子,就是说在通知栏显示一条含图标、标题等的通知,用户点击可打开您指定的网页
    template = LinkTemplate()
    template.appId = APPID
    template.appKey = APPKEY
    template.title = u"欢迎使用个推 gs!"
    template.text = u"这是一条single推送消息"
    template.logo = ""
    template.url = "http://www.baidu.com"
    template.transmissionType = 1
    template.transmissionContent = ''
    template.isRing = True
    template.isVibrate = True
    template.isClearable = True
    # template = NotyPopLoadTemplateDemo()
    #     iOS setAPNInfo
    apnpayload = APNPayload()
    apnpayload.badge = 4
    apnpayload.sound = "sound"
    apnpayload.addCustomMsg("payload", "payload")
    #     apnpayload.contentAvailable = 1
    #     apnpayload.category = "ACTIONABLE"

    alertMsg = DictionaryAlertMsg()
    alertMsg.body = 'body'
    alertMsg.actionLocKey = 'actionLockey'
    alertMsg.locKey = 'lockey'
    alertMsg.locArgs = ['locArgs']
    alertMsg.launchImage = 'launchImage'
    # iOS8.2以上版本支持
    #     alertMsg.title = 'Title'
    #     alertMsg.titleLocArgs = ['TitleLocArg']
    #     alertMsg.titleLocKey = 'TitleLocKey'
    apnpayload.alertMsg = alertMsg
    template.setApnInfo(apnpayload)

    message = IGtSingleMessage()
    message.isOffline = True
    message.offlineExpireTime = 1000 * 3600 * 12
    message.data = template
    # message.pushNetWorkType = 2

    target = Target()
    target.appId = APPID
    target.clientId = CID

    try:
        ret = push.pushMessageToSingle(message, target)
        print ret
    except RequestException, e:
        requstId = e.getRequestId()
        ret = push.pushMessageToSingle(message, target, requstId)
        print ret
Ejemplo n.º 12
0
def pushMessageToSingle3(cid, title, text):
    # http的接口
    # push = IGeTui(None, APPKEY, MASTERSECRET,False)
    # https的接口
    # push = IGeTui(None, APPKEY, MASTERSECRET,True)
    # 根据HOST区分是https还是http
    # push = IGeTui(HOST, APPKEY, MASTERSECRET)
    print 'appid,', APPID
    if GetuiPush.push is None:
        GetuiPush.push = IGeTui(HOST, APPKEY, MASTERSECRET)
    push = GetuiPush.push
    # 消息模版:
    # 1.TransmissionTemplate:透传功能模板
    # 2.LinkTemplate:通知打开链接功能模板
    # 3.NotificationTemplate:通知透传功能模板
    # 4.NotyPopLoadTemplate:通知弹框下载功能模板

    #     template = NotificationTemplateDemo()
    # template = LinkTemplateDemo()
    # 新建一个推送模版, 以链接模板为例子,就是说在通知栏显示一条含图标、标题等的通知,用户点击可打开您指定的网页
    template = TransmissionTemplate()
    template.transmissionType = 1
    template.appId = APPID
    template.appKey = APPKEY
    template.transmissionContent = '请输入您要透传内容'
    #     iOS setAPNInfo
    apnpayload = APNPayload()
    apnpayload.badge = 4
    apnpayload.sound = "sound"
    apnpayload.addCustomMsg("payload", "payload")
    #     apnpayload.contentAvailable = 1
    #     apnpayload.category = "ACTIONABLE"

    alertMsg = DictionaryAlertMsg()
    alertMsg.body = 'body'
    alertMsg.actionLocKey = 'actionLockey'
    alertMsg.locKey = 'lockey'
    alertMsg.locArgs = ['locArgs']
    alertMsg.launchImage = 'launchImage'
    # iOS8.2以上版本支持
    alertMsg.title = 'Title'
    alertMsg.titleLocArgs = ['TitleLocArg']
    alertMsg.titleLocKey = 'TitleLocKey'
    apnpayload.alertMsg = alertMsg
    template.setApnInfo(apnpayload)

    message = IGtSingleMessage()
    message.isOffline = False
    message.offlineExpireTime = 1000 * 3600 * 12
    message.data = template
    # message.pushNetWorkType = 2

    target = Target()
    target.appId = APPID
    target.clientId = cid

    try:
        ret = push.pushMessageToSingle(message, target)
        print ret
        return ret
    except RequestException, e:
        requstId = e.getRequestId()
        ret = push.pushMessageToSingle(message, target, requstId)
        print ret