python 微信公众号-回调模式验证url
2016-07-28 17:15
686 查看
回调模式
###微信公众号回调模式之验证URL from flask import Flask,request from WXBizMsgCrypt import WXBizMsgCrypt import xml.etree.cElementTree as ET import sys app = Flask(__name__) @app.route('/index',methods=['GET','POST']) def index(): sToken = 'XXX' #Token sEncodingAESKey = 'Uxxxxxxxxxxxxxxxxxxxxxxxxxxxxo' #EncodingAESKey sCorpID = 'wx1xxxxxxxxxxxxxxxxxx' #CorpID wxcpt=WXBizMsgCrypt(sToken,sEncodingAESKey,sCorpID) sVerifyMsgSig=request.args.get('msg_signature') #获取微信验证发过来的请求参数msg_signature sVerifyTimeStamp=request.args.get('timestamp') #获取微信验证发过来的请求参数timestamp sVerifyNonce=request.args.get('nonce') #获取微信验证发过来的请求参数nonce sVerifyEchoStr=request.args.get('echostr') #获取微信验证发过来的请求参数echostr ret,sEchoStr=wxcpt.VerifyURL(sVerifyMsgSig, sVerifyTimeStamp,sVerifyNonce,sVerifyEchoStr) if (ret != 0 ): print "ERR: VerifyURL ret:" + ret sys.exit(1) return sEchoStr #返回解密后的EchoStr if __name__ == '__main__': app.run(host='0.0.0.0',port=6000,debug=True)
相关文章推荐
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- python的numpy模块安装问题
- BeautifulSoup使用一两则(不定期补充)
- 用virtual environment让库管理变得简单
- Python线程优先级队列(Queue)
- Python线程同步
- Python 命名空间和LEGB规则
- 【leetcode】377. Combination Sum IV【M】
- Python使用Threading模块创建线程
- tornodo使用(一)
- Python 爬虫1——爬虫简述