微信公众号配置服务器地址校验token不通过
服务器后端要实现相关校验接口
def get(self, request):
"""
校验token
"""
data = request.query_params
signature = data.get('signature')
timestamp = data.get('timestamp')
nonce = data.get('nonce')
echostr = data.get('echostr')
token = 'xxxx'
list_s = [token, timestamp, nonce]
list_s.sort()
hashcode = hashlib.sha1(''.join(list_s).encode('utf-8')).hexdigest()
if hashcode == signature:
return HttpResponse(content=echostr.encode('utf-8'))
else:
return HttpResponse(content=''.encode('utf-8'))