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


Python WechatBasic.check_signature方法代码示例

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


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

示例1: index

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def index(request):

    # 实例化 We_chat_Basic
    we_chat = WechatBasic(token=WECHAT_TOKEN, appid=AppID, appsecret=AppSecret)
    if request.method == "GET":
        signature = request.GET.get("signature")
        timestamp = request.GET.get("timestamp")
        nonce = request.GET.get("nonce")
        if not we_chat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
            return HttpResponse("Verify failed")
        else:
            return HttpResponse(request.GET.get("echostr"), content_type="text/plain")
    else:
        signature = request.GET.get("signature")
        timestamp = request.GET.get("timestamp")
        nonce = request.GET.get("nonce")
        if not we_chat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
            return HttpResponse("Verify failed")
        try:
            we_chat.parse_data(data=request.body)
        except ParseError:
            return HttpResponseBadRequest("Invalid XML Data")
        message = we_chat.get_message()
        if isinstance(message, EventMessage):
            if message.type == "click":
                if message.key == "STEP_COUNT":
                    step_array = Record.objects.filter(user=message.source)
                    if step_array:
                        step = step_array[len(step_array) - 1].step
                        response = we_chat.response_text("跑了" + str(step) + "步咯")
                        # 里面的数字应由其他函数获取
                        return HttpResponse(response)
                    else:
                        response = we_chat.response_text("Sorry, there' no data about you in our database.")
                        return HttpResponse(response)
                if message.key == "CHART":
                    print 1
                    response = we_chat.response_news(
                        [
                            {
                                "title": "Today's amount of exercise",
                                "description": "data analysis",
                                "picurl": "http://7xn2s5.com1.z0.glb.clouddn.com/ez.png",
                                "url": SERVER_IP + "TodayChart/" + message.source,
                            }
                        ]
                    )
                    return HttpResponse(response)
        response = we_chat.response_text("Cheer up!")
        return HttpResponse(response)
开发者ID:xujingao13,项目名称:Arrange,代码行数:52,代码来源:views.py

示例2: test_check_signature

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
    def test_check_signature(self):
        signature = '41f929117dd6231a953f632cfb3be174b8e3ef08'
        timestamp = '1434295379'
        nonce = 'ueivlkyhvdng46da0qxr52qzcjabjmo7'

        # 测试无 Token 初始化
        wechat = WechatBasic()
        with self.assertRaises(NeedParamError):
            wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce)

        # 测试有 Token 初始化
        wechat = WechatBasic(token=self.token)
        self.assertTrue(wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce))
        self.assertFalse(wechat.check_signature(signature=signature, timestamp=timestamp+'2', nonce=nonce))
开发者ID:14F,项目名称:wechat-python-sdk,代码行数:16,代码来源:test_basic.py

示例3: index

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def index(request):
 
    # 实例化 We_chat_Basic
    we_chat = WechatBasic(
        token=WECHAT_TOKEN,
        appid=AppID,
        appsecret=AppSecret
    )
    if request.method == "GET":
        signature = request.GET.get('signature')
        timestamp = request.GET.get('timestamp')
        nonce = request.GET.get('nonce')
        if not we_chat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
            return HttpResponse("Verify failed")
        else:
            return HttpResponse(request.GET.get("echostr"), content_type="text/plain")
    else:
        signature = request.GET.get('signature')
        timestamp = request.GET.get('timestamp')
        nonce = request.GET.get('nonce')
        if not we_chat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
            return HttpResponse("Verify failed")
        try:
            we_chat.parse_data(data=request.body)
        except ParseError:
            return HttpResponseBadRequest('Invalid XML Data')
        message = we_chat.get_message()
        if isinstance(message, EventMessage):
            if message.type == 'click':
                if message.key == 'STEP_COUNT':
                    step_array = Record.objects.filter(user=message.source)
                    if step_array:
                        step = step_array[len(step_array) - 1].step
                        response = we_chat.response_text(u'跑了' + str(step) + u'步咯')
                        # 里面的数字应由其他函数获取
                        return HttpResponse(response)
                    else:
                        response = we_chat.response_text(u'Sorry, there\' no data about you in our database.')
                        return HttpResponse(response)
                if message.key == 'CHART':
                    print 1
                    response = we_chat.response_news([{
                        'title': u'Today\'s amount of exercise',
                        'description': 'data analysis',
                        'picurl': 'http://7xn2s5.com1.z0.glb.clouddn.com/ez.png',
                        'url': SERVER_IP + 'TodayChart/' + message.source}])
                    return HttpResponse(response)
        response = we_chat.response_text(u'Cheer up!')
        return HttpResponse(response)
开发者ID:Software-Eng-THU-2015,项目名称:TreasureRing,代码行数:51,代码来源:views.py

示例4: weixin_response

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def weixin_response(token, signature, timestamp, nonce, body_text=''):
    debug_log('check sign ...\n')
    # 用户的请求内容 (Request 中的 Body)
    # 请更改 body_text 的内容来测试下面代码的执行情况

    # 实例化 wechat
    wechat = WechatBasic(token=token)
    # 对签名进行校验
    if wechat.check_signature(signature, timestamp, nonce):
        # 对 XML 数据进行解析 (必要, 否则不可执行 response_text, response_image 等操作)
        wechat.parse_data(body_text)
        # 获得解析结果, message 为 WechatMessage 对象 (wechat_sdk.messages中定义)
        message = wechat.get_message()

        response = None
        if message.type == 'text':
            if message.content == 'wechat':
                response = wechat.response_text(u'^_^')
            else:
                response = wechat.response_text(u'文字')
        elif message.type == 'image':
            response = wechat.response_text(u'图片')
        else:
            response = wechat.response_text(u'未知')

        # 现在直接将 response 变量内容直接作为 HTTP Response 响应微信服务器即可,此处为了演示返回内容,直接将响应进行输出
        return response
    return HttpResponse('')
开发者ID:bearicc,项目名称:geohomeusa,代码行数:30,代码来源:views.py

示例5: entrance

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def entrance(request):
    def get_access_token():
        url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='+APP_ID+'&secret='+APP_SECRET
        access_token = get_rsp_data(url)['access_token']
        return access_token

    def get_user_info():
        access_token = get_access_token()
        url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token='+access_token+'&openid='+message.source
        ueser_info_dic = get_rsp_data(url)
        user_info = ""
        for k, v in ueser_info_dic.items():
            user_info = user_info+str(k)+":"+str(v)+"\n"
        return user_info

    def OAuth():
        REDIRECT_URL = 'http://115.159.160.143/oauth'
        url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+APP_ID+'&redirect_uri='+REDIRECT_URL+'&response_type=code&scope=snsapi_userinfo&state=2#wechat_redirect=0'
        rsp = '<a href="'+url+'">点我授权</a>'
        return rsp

    wechat = WechatBasic(token=TOKEN)
    if wechat.check_signature(signature=request.GET['signature'],
                              timestamp=request.GET['timestamp'],
                              nonce=request.GET['nonce']):
        if request.method == 'GET':
            rsp = request.GET.get('echostr', 'error')
        else:
            wechat.parse_data(request.body)
            message = wechat.get_message()
            rsp = wechat.response_text(OAuth())
    else:
        rsp = "failed"
    return HttpResponse(rsp)
开发者ID:Agosits,项目名称:weixin,代码行数:36,代码来源:views.py

示例6: home

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def home(request):
    token = TOKEN
    if request.method == 'POST':
        signature = request.POST.get('signature', '')
        timestamp = request.POST.get('timestamp', '')
        nonce = request.POST.get('nonce')
    elif request.method == 'GET':
        signature = request.GET.get('signature', '')
        timestamp = request.GET.get('timestamp', '')
        nonce = request.GET.get('nonce')
        echostr = request.GET.get('echostr', '')

    if DEBUG:
        debug_log('==========')
        debug_log('token: '+str(token))
        debug_log('signature: '+str(signature))
        debug_log('timestamp: '+str(timestamp))
        debug_log('nonce: '+str(nonce))

    if token and timestamp and nonce and echostr:
        s = ''.join(sorted([token,timestamp,nonce]))
        debug_log('calculated sign: '+hashlib.sha1(s.encode('utf-8')).hexdigest())
        debug_log('echostr: '+str(echostr))
        wechat = WechatBasic(token=token)
        # 对签名进行校验
        if wechat.check_signature(signature, timestamp, nonce):
             return HttpResponse(echostr)
        else:
             return HttpResponse('')

    if signature:
        return weixin_response(token, signature, timestamp, nonce, request.body)
    return HttpResponse('<h1>微信开发中 ...</h1>')

    """
开发者ID:bearicc,项目名称:geohomeusa,代码行数:37,代码来源:views.py

示例7: wechatChatForFun

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def wechatChatForFun(request):
    signature = request.GET.get('signature')
    timestamp = request.GET.get('timestamp')
    nonce = request.GET.get('nonce')
    wechat_instance = WechatBasic(conf=ChatForFunConf)
    reply_text = ""
    if not wechat_instance.check_signature(
            signature=signature, timestamp=timestamp, nonce=nonce):
        return HttpResponseBadRequest('Verify Failed')
    else:
        if request.method == 'GET':
            response = request.GET.get('echostr', 'error')
        else:
            try:
                wechat_instance.parse_data(request.body)
                message = wechat_instance.get_message()
                if isinstance(message, TextMessage):
                    reply_text = str(message.content).encode('utf8')
                    reply_text = ParserMsg(reply_text, message.source)
                elif isinstance(message, ImageMessage):
                    reply_text = str(message.picurl).encode('utf8')
                    reply_text = ParserMsg(reply_text, message.source)
                elif isinstance(message, LocationMessage):
                    reply_text = str(message.label).encode('utf8')
                    reply_text = ParserMsg(reply_text, message.source)
                else:
                    reply_text = U"服务器:目前只支持文字消息,非常抱歉"

                response = wechat_instance.response_text(content=reply_text)
            except ParseError:
                return HttpResponseBadRequest("Invalid XML Data")
        return HttpResponse(response, content_type='application/xml')
开发者ID:DennisMi1024,项目名称:WeChatServer,代码行数:34,代码来源:views.py

示例8: validate

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def validate():
    signature = request.args.get('signature')
    echostr = request.args.get('echostr')
    timestamp = request.args.get('timestamp')
    nonce = request.args.get('nonce')

    token = "test"

    body_text = request.get_data()

    # 实例化 wechat
    wechat = WechatBasic(token=token)
    # 对签名进行校验
    if wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
        # 对 XML 数据进行解析 (必要, 否则不可执行 response_text, response_image 等操作)
        wechat.parse_data(body_text)
        # 获得解析结果, message 为 WechatMessage 对象 (wechat_sdk.messages中定义)
        message = wechat.get_message()

        response = None

        if message.type == 'subscribe':
            response = wechat.response_text("谢谢关注V2EX热帖分享,输入任意内容以获取最新热帖咨询")

        if message.type == 'text':
            newsList = generate()
            response = wechat.response_news(newsList)

        # 现在直接将 response 变量内容直接作为 HTTP Response 响应微信服务器即可,此处为了演示返回内容,直接将响应进行输出
        return response
开发者ID:ieiayaobb,项目名称:v2ex_push,代码行数:32,代码来源:Application.py

示例9: weixin

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def weixin(request):
    wechat = WechatBasic(token=token)
    if wechat.check_signature(signature=request.GET['signature'],
                              timestamp=request.GET['timestamp'],
                              nonce=request.GET['nonce']):
        if request.method == 'GET':
            rsp = request.GET.get('echostr', 'error')
        else:
            wechat.parse_data(request.body)
            message = wechat.get_message()
            # write_log(message.type)
            if message.type == u'text':
                response_content = 'this is text'
                # response_content = handle_text(message.content)
                if message.content == u'wechat':
                    # response_content = 'hello wechat'
                    rsp = wechat.response_text(u'^_^')
                elif re.findall(u'锐捷', message.content):
                    rsp = wechat.response_news(ruijie_response)
                else:
                    rsp = wechat.response_news(default_response)
            else:
                # rsp = wechat.response_text(u'消息类型: {}'.format(message.type))
                rsp = wechat.response_news(default_response)

    else:
        rsp = wechat.response_text('check error')
    return HttpResponse(rsp)
开发者ID:pierre94,项目名称:python-django-cd-sample,代码行数:30,代码来源:views.py

示例10: index

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def index(request):
    signature = request.GET.get('signature')
    timestamp = request.GET.get('timestamp')
    nonce = request.GET.get('nonce')
    xml = request.body
    body_text = """
        <xml>
        <ToUserName><![CDATA[touser]]></ToUserName>
        <FromUserName><![CDATA[fromuser]]></FromUserName>
        <CreateTime>1405994593</CreateTime>
        <MsgType><![CDATA[text]]></MsgType>
        <Content><![CDATA[新闻]]></Content>
        <MsgId>6038700799783131222</MsgId>
        </xml>
    """
    token = get_weixin_accesstoken()
    # 实例化 wechat
    wechat = WechatBasic(token=token)
    # 对签名进行校验
    if wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
        # 对 XML 数据进行解析 (必要, 否则不可执行 response_text, response_image 等操作)
        wechat.parse_data(body_text)
        # 获得解析结果, message 为 WechatMessage 对象 (wechat_sdk.messages中定义)
        message = wechat.get_message()

        response = None
        if isinstance(message, TextMessage):
            response = wechat.response_text(content=u'文字信息')
        elif isinstance(message, VoiceMessage):
            response = wechat.response_text(content=u'语音信息')
        elif isinstance(message, ImageMessage):
            response = wechat.response_text(content=u'图片信息')
        elif isinstance(message, VideoMessage):
            response = wechat.response_text(content=u'视频信息')
        elif isinstance(message, LinkMessage):
            response = wechat.response_text(content=u'链接信息')
        elif isinstance(message, LocationMessage):
            response = wechat.response_text(content=u'地理位置信息')
        elif isinstance(message, EventMessage):  # 事件信息
            if message.type == 'subscribe':  # 关注事件(包括普通关注事件和扫描二维码造成的关注事件)
                if message.key and message.ticket:  # 如果 key 和 ticket 均不为空,则是扫描二维码造成的关注事件
                    response = wechat.response_text(content=u'用户尚未关注时的二维码扫描关注事件')
                else:
                    response = wechat.response_text(content=u'普通关注事件')
            elif message.type == 'unsubscribe':
                response = wechat.response_text(content=u'取消关注事件')
            elif message.type == 'scan':
                response = wechat.response_text(content=u'用户已关注时的二维码扫描事件')
            elif message.type == 'location':
                response = wechat.response_text(content=u'上报地理位置事件')
            elif message.type == 'click':
                response = wechat.response_text(content=u'自定义菜单点击事件')
            elif message.type == 'view':
                response = wechat.response_text(content=u'自定义菜单跳转链接事件')
            elif message.type == 'templatesendjobfinish':
                response = wechat.response_text(content=u'模板消息事件')

        # 现在直接将 response 变量内容直接作为 HTTP Response 响应微信服务器即可,此处为了演示返回内容,直接将响应进行输出
        print response
        return render_to_response('index.html',response)
开发者ID:blendedlearn,项目名称:blended_learning,代码行数:62,代码来源:views.py

示例11: post

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
	def post(self):
		# 实例化 wechat
		wechat = WechatBasic(token=token)
		signature = self.get_argument("signature", None)
		timestamp = self.get_argument("timestamp", None)
		nonce = self.get_argument("nonce", None)
        # 对签名进行校验
		if wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
		    # 对 XML 数据进行解析 (必要, 否则不可执行 response_text, response_image 等操作)
		    # look request method
			# print dir(self.request)
		    content = self.request.body
		    wechat.parse_data(content)
		    # 获得解析结果, message 为 WechatMessage 对象 (wechat_sdk.messages中定义)
		    message = wechat.get_message()

		    response = None
		    if message.type == 'text':
		        if message.content == 'wechat':
		        	response = wechat.response_text(u'''
		        		<a href="https://open.weixin.qq.com/connect/oauth2/authorize?
		        		appid=wxafac6b4bc457eb26&redirect_uri=http://tuteng.info/login_access&
		        		response_type=code&scope=snsapi_userinfo&state=14#wechat_redirect">testtt</a>
		        		''')
		        else:
		            response = wechat.response_text(u'world')
		    elif message.type == 'image':
		        response = wechat.response_text(u'image')
		    else:
		        response = wechat.response_text(u'no image')
开发者ID:tuteng,项目名称:authorization,代码行数:32,代码来源:test_success.py

示例12: smart_entry

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def smart_entry(request):
    signature = request.REQUEST.get('signature', None)
    timestamp = request.REQUEST.get('timestamp', None)
    nonce = request.REQUEST.get('nonce', None)

    # if it's account authenticate request
    echostr = request.REQUEST.get('echostr', None)
    if echostr:
        return HttpResponse(echostr)

    wechat = WechatBasic(token=settings.WECHAT_TOKEN, appid=settings.WECHAT_ACCOUNT)

    # 对签名进行校验
    if wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
        # 对 XML 数据进行解析 (必要, 否则不可执行 response_text, response_image 等操作)
        body_text = request.body
        wechat.parse_data(body_text)
        # 获得解析结果, message 为 WechatMessage 对象 (wechat_sdk.messages中定义)
        message = wechat.get_message()

        response = None
        if isinstance(message, TextMessage):
            response = wechat.response_text(content=u'文字信息')
        elif isinstance(message, VoiceMessage):
            response = wechat.response_text(content=u'语音信息')
        elif isinstance(message, ImageMessage):
            response = wechat.response_text(content=u'图片信息')
        elif isinstance(message, VideoMessage):
            response = wechat.response_text(content=u'视频信息')
        elif isinstance(message, LinkMessage):
            response = wechat.response_text(content=u'链接信息')
        elif isinstance(message, LocationMessage):
            response = wechat.response_text(content=u'地理位置信息')
        elif isinstance(message, EventMessage):  # 事件信息
            if message.type == 'subscribe':  # 关注事件(包括普通关注事件和扫描二维码造成的关注事件)
                if message.key and message.ticket:  # 如果 key 和 ticket 均不为空,则是扫描二维码造成的关注事件
                    response = wechat.response_text(content=u'用户尚未关注时的二维码扫描关注事件')
                else:
                    response = wechat.response_text(content=u'普通关注事件')
            elif message.type == 'unsubscribe':
                response = wechat.response_text(content=u'取消关注事件')
            elif message.type == 'scan':
                response = wechat.response_text(content=u'用户已关注时的二维码扫描事件')
            elif message.type == 'location':
                response = wechat.response_text(content=u'上报地理位置事件')
            elif message.type == 'click':
                response = wechat.response_text(content=u'自定义菜单点击事件')
            elif message.type == 'view':
                response = wechat.response_text(content=u'自定义菜单跳转链接事件')
            elif message.type == 'templatesendjobfinish':
                response = wechat.response_text(content=u'模板消息事件')

        return HttpResponse(response)

    return HttpResponse("Not implemented yet")
开发者ID:hewenhao2008,项目名称:wechat-smart,代码行数:57,代码来源:views.py

示例13: validate

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def validate():
    wechat = WechatBasic(token=settings['wechat_app']['token'], appid=settings['wechat_app']['appID'],
                         appsecret=settings['wechat_app']['appsecret'])
    signature = request.args.get('signature')
    timestamp = request.args.get('timestamp')
    nonce = request.args.get('nonce')
    # log the checking event
    logger.info("checking signature: (%s, %s, %s)", signature, timestamp, nonce)
    if wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
        return request.args.get('echostr')
    return ""
开发者ID:qcs4tracy,项目名称:webchat_service,代码行数:13,代码来源:basic.py

示例14: index

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def index():
    token = settings.TOKEN
    signature = request.args.get('signature', '')
    timestamp = request.args.get('timestamp', '')
    nonce = request.args.get('nonce', '')

    # 实例化 wechat
    wechat = WechatBasic(token=token)

    if not wechat.check_signature(signature=signature,
                                  timestamp=timestamp, nonce=nonce):
        return 'fail'

    # 对签名进行校验
    echostr = request.args.get('echostr')
    if echostr:
        return echostr

    wechat.parse_data(request.data)
    message = wechat.get_message()
    if message.type == 'text':
        response = wechat.group_transfer_message()
    elif message.type == 'image':
        response = wechat.response_text(u'图片')
    elif isinstance(message, EventMessage):
        if message.type == 'subscribe':
            if message.key and message.ticket:
                scene = message.key.startswith(
                    'qrscene_') and message.key[8:] or 'default'
            else:
                scene = 'default'

            SubscribeEvent.create_event(message.source, scene, message.time)
            response = wechat.response_text(content=settings.GREETINGS)

        elif message.type == 'unsubscribe':
            UnsubscribeEvent.create_event(message.source, message.time)
            # TODO
            response = ''
        elif message.type == 'scan':
            # TODO
            response = ''
        elif message.type == 'location':
            response = wechat.response_text(content=u'上报地理位置事件')
        elif message.type == 'click':
            content = settings.CLICK_MENU_TEXT_MAPPER.get(message.key, u'未知')
            response = wechat.response_text(content=content)
        elif message.type == 'view':
            response = wechat.response_text(content=u'自定义菜单跳转链接事件')
        elif message.type == 'templatesendjobfinish':
            response = wechat.response_text(content=u'模板消息事件')
    else:
        response = wechat.response_text(u'未知')
    return response
开发者ID:FashtimeDotCom,项目名称:wechat-admin,代码行数:56,代码来源:views.py

示例15: handleRequest

# 需要导入模块: from wechat_sdk import WechatBasic [as 别名]
# 或者: from wechat_sdk.WechatBasic import check_signature [as 别名]
def handleRequest(request):
    signature = request.GET.get("signature", '')
    timestamp = request.GET.get("timestamp", '')
    nonce = request.GET.get("nonce", '')
    wechat = WechatBasic(token=TOKEN)
    if request.method == 'GET':
        echoStr = request.GET.get("echostr", '')
        if wechat.check_signature(signature, timestamp, nonce):
            response = HttpResponse(echoStr, content_type="text/plain")
        else:
            response = HttpResponse('', content_type="text/plain")
        return response
    elif request.method == 'POST':
        if wechat.check_signature(signature, timestamp, nonce):
            response = HttpResponse(responseMsg(request, wechat), content_type="application/xml")
        else:
            response = HttpResponse('', content_type="application/xml")

        return response
    else:
        return HttpResponse('', content_type="application/xml")
开发者ID:fanjunwei,项目名称:fjwdj,代码行数:23,代码来源:views_api.py


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