赞
踩
示例代码:
class WeiXinToken(APIView):
def get (self, request ):
signature = request.GET.get ( 'signature' )
timestamp = request.GET.get ( 'timestamp' )
nonce = request.GET.get ( 'nonce' )
echostr = request.GET.get ( 'echostr' )
token = "*******填写后台配置的Token令牌********"
tmpArr = [ token, timestamp, nonce ]
tmpArr.sort ()
string = ''.join ( tmpArr ).encode ( 'utf-8' )
string = hashlib.sha1 ( string ).hexdigest ()
if string == signature:
return HttpResponse ( echostr )
else:
return HttpResponse ( "false" )
class WeiXinToken(APIView): """当前只获取到了xml 信息, 后续更新""" def post(self,request): signature = request.GET.get ( 'signature' ) timestamp = request.GET.get ( 'timestamp' ) nonce = request.GET.get ( 'nonce' ) msg_sign = request.GET.get ( 'msg_signature' ) token = "*******填写后台配置的Token令牌********" encodingAESKey = "*****对应后台配置的消息加密密钥*****" _xml = request.body # 拿到微信发送的xml请求 即微信支付后的回调内容 xml = str(_xml, encoding="utf-8") # 解密模块 decrypt_test = WXBizMsgCrypt(token, encodingAESKey, APP_ID) ret, decryp_xml = decrypt_test.DecryptMsg(xml, msg_sign, timestamp, nonce) print(ret, decryp_xml) return HttpResponse("SUCCESS")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。