微信公众号

微信公众号

微信公众号后台的签名校验的官方教程在python3下不兼容

python李魔佛 发表了文章 • 0 个评论 • 2206 次浏览 • 2020-12-11 11:43 • 来自相关话题

感觉写这个文档的人是个菜鸡。 
首先文档用的python2代码写的,但文中没有标明。
 
 
python2旧就算了,而且那么多框架不用,还要用一个老掉牙的web.py来写,也是醉了。
 
django下的签名校验:token = '123456789'
def Services(request):
print(request.method)
if request.method=='GET':

signature = request.GET.get('signature')
echostr = request.GET.get('echostr')
timestamp = request.GET.get('timestamp')
nonce = request.GET.get('nonce')
list_ = [token, timestamp, nonce]
list_.sort()
list_str = ''.join(list_)

sha1 = hashlib.sha1(list_str.encode('utf8'))
hashcode = sha1.hexdigest()
if hashcode==signature:
return HttpResponse(echostr)
else:
return HttpResponse('')
原创文章,转载请注明出处http://30daydo.com/article/44121
 
 
  查看全部
感觉写这个文档的人是个菜鸡。 
首先文档用的python2代码写的,但文中没有标明。
 
 
python2旧就算了,而且那么多框架不用,还要用一个老掉牙的web.py来写,也是醉了。
 
django下的签名校验:
token = '123456789'
def Services(request):
print(request.method)
if request.method=='GET':

signature = request.GET.get('signature')
echostr = request.GET.get('echostr')
timestamp = request.GET.get('timestamp')
nonce = request.GET.get('nonce')
list_ = [token, timestamp, nonce]
list_.sort()
list_str = ''.join(list_)

sha1 = hashlib.sha1(list_str.encode('utf8'))
hashcode = sha1.hexdigest()
if hashcode==signature:
return HttpResponse(echostr)
else:
return HttpResponse('')

原创文章,转载请注明出处http://30daydo.com/article/44121
 
 
 

微信公众号后台的签名校验的官方教程在python3下不兼容

python李魔佛 发表了文章 • 0 个评论 • 2206 次浏览 • 2020-12-11 11:43 • 来自相关话题

感觉写这个文档的人是个菜鸡。 
首先文档用的python2代码写的,但文中没有标明。
 
 
python2旧就算了,而且那么多框架不用,还要用一个老掉牙的web.py来写,也是醉了。
 
django下的签名校验:token = '123456789'
def Services(request):
print(request.method)
if request.method=='GET':

signature = request.GET.get('signature')
echostr = request.GET.get('echostr')
timestamp = request.GET.get('timestamp')
nonce = request.GET.get('nonce')
list_ = [token, timestamp, nonce]
list_.sort()
list_str = ''.join(list_)

sha1 = hashlib.sha1(list_str.encode('utf8'))
hashcode = sha1.hexdigest()
if hashcode==signature:
return HttpResponse(echostr)
else:
return HttpResponse('')
原创文章,转载请注明出处http://30daydo.com/article/44121
 
 
  查看全部
感觉写这个文档的人是个菜鸡。 
首先文档用的python2代码写的,但文中没有标明。
 
 
python2旧就算了,而且那么多框架不用,还要用一个老掉牙的web.py来写,也是醉了。
 
django下的签名校验:
token = '123456789'
def Services(request):
print(request.method)
if request.method=='GET':

signature = request.GET.get('signature')
echostr = request.GET.get('echostr')
timestamp = request.GET.get('timestamp')
nonce = request.GET.get('nonce')
list_ = [token, timestamp, nonce]
list_.sort()
list_str = ''.join(list_)

sha1 = hashlib.sha1(list_str.encode('utf8'))
hashcode = sha1.hexdigest()
if hashcode==signature:
return HttpResponse(echostr)
else:
return HttpResponse('')

原创文章,转载请注明出处http://30daydo.com/article/44121