django比较符合个人风格、于是乎拿django搭建个微信后台玩玩、、结果无比坑爹
def checkSignature(request):
token = 'jasonbu'
signature = request.GET.get('signature', '')
timestamp = request.GET.get('timestamp', '')
nonce = request.GET.get('nonce', '')
echostr = request.GET.get('echostr', '')
infostr = ''.join(sorted([token, timestamp, nonce]))
if infostr:
hashstr = hashlib.sha1(infostr).hexdigest()
print 'signature:' + signature
print 'hashstr:' + hashstr
#if hashstr is signature:
if hashstr == signature:
return HttpResponse(echostr)
else:
print 'haststr is not signature'
else:
print 'infostr does not existing'
return HttpResponse("what")
测试了N多次还是失败 见鬼了、、 打印出来都一模一样、、
然后说试试把is换成 ==
可以了。。。
装wechat-sdk环境 少头文件、解决办法
sudo apt-get install python-dev
为了测试装了个lxml
sudo apt-get build-dep python-lxml
sudo pip install lxml --upgrade
2
我想哭了、、 折腾了好久 最后居然是服务器配置的时候少一个 '/' 加上就一切正常了 TAT