- import hashlib
- from django.http import HttpResponse
- def index(request):
- signature = request.GET['signature']
- timestamp = request.GET['timestamp']
- nonce = request.GET['nonce']
- token = 'test_token' # 替换成自己的 token
- tmp = [token, timestamp, nonce]
- tmp.sort()
- s = ''.join(tmp)
- s = hashlib.sha1(s).hexdigest()
- if s == signature:
- return HttpResponse(request.GET['echostr'])
- #该片段来自于http://www.codesnippet.cn/detail/2407201410052.html
来源: http://www.codesnippet.cn/detail/2407201410052.html