接入微信
微信官方文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1445241432
先进去按步骤进行
其中第二步:验证消息的确来自微信服务器
django中实现代码
def get(request):
signature = request.GET.get('signature')
timestamp = request.GET.get('timestamp')
nonce = request.GET.get('nonce')
echostr = request.GET.get('echostr')
token = "weixin"
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")
接入成功后按照官方文档进行逻辑编写即可