| @@ -5,6 +5,7 @@ TimeConvert==1.2.0 | ||
| 5 | 5 | cryptography==1.2.1 | 
| 6 | 6 | django-curtail-uuid==1.0.0 | 
| 7 | 7 | django-detect==1.0.4 | 
| 8 | +django-json-response==1.1.3 | |
| 8 | 9 | django-logit==1.0.2 | 
| 9 | 10 | django-multidomain==1.1.4 | 
| 10 | 11 | django-shortuuidfield==0.1.3 | 
| @@ -4,7 +4,7 @@ import time | ||
| 4 | 4 |  | 
| 5 | 5 | import shortuuid | 
| 6 | 6 | from django.conf import settings | 
| 7 | -from django.http import HttpResponse | |
| 7 | +from json_response import auto_response | |
| 8 | 8 | from wechatpy import WeChatClient | 
| 9 | 9 |  | 
| 10 | 10 |  | 
| @@ -13,9 +13,9 @@ WECHAT = settings.WECHAT | ||
| 13 | 13 |  JSAPI = WECHAT.get('JSAPI', {}) | 
| 14 | 14 |  | 
| 15 | 15 |  | 
| 16 | +@auto_response | |
| 16 | 17 | def wx_jsapi_signature_api(request): | 
| 17 | 18 |      url = request.GET.get('url', '') | 
| 18 | -    callback = request.GET.get('callback', '') | |
| 19 | 19 |  | 
| 20 | 20 | nonceStr, timestamp = shortuuid.uuid(), int(time.time()) | 
| 21 | 21 |  | 
| @@ -23,9 +23,9 @@ def wx_jsapi_signature_api(request): | ||
| 23 | 23 | ticket = client.jsapi.get_jsapi_ticket() | 
| 24 | 24 | signature = client.jsapi.get_jsapi_signature(nonceStr, ticket, timestamp, url) | 
| 25 | 25 |  | 
| 26 | -    return HttpResponse('{}({})'.format(callback, { | |
| 26 | +    return { | |
| 27 | 27 | 'appId': JSAPI['appID'], | 
| 28 | 28 | 'nonceStr': nonceStr, | 
| 29 | 29 | 'timestamp': timestamp, | 
| 30 | 30 | 'signature': signature, | 
| 31 | - })) | |
| 31 | + } |