{"id":29283,"date":"2024-11-25T08:07:53","date_gmt":"2024-11-25T00:07:53","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29283\/"},"modified":"2024-11-25T08:07:53","modified_gmt":"2024-11-25T00:07:53","slug":"%e5%be%ae%e4%bf%a1%e5%85%ac%e4%bc%97%e8%b4%a6%e5%8f%b7%e5%bc%80%e5%8f%91%ef%bc%9aurl-%e5%92%8c-tocken%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29283\/","title":{"rendered":"\u5fae\u4fe1\u516c\u4f17\u8d26\u53f7\u5f00\u53d1\uff1aURL \u548c Tocken\u4ecb\u7ecd"},"content":{"rendered":"<p>\u4e00\u3001url \u548c tocken \u7b80\u4ecb<\/p>\n<p>1\u3001\u60f3\u6210\u4e3a\u5f00\u53d1\u8005\u5fc5\u987b\u8981\u6709\u4e00\u4e2a\u516c\u7f51\u7684\u7f51\u7edc\u5730\u5740\uff08URL\uff09\uff0c\u8fd9\u4e2a\u7f51\u7edc\u5730\u5740\u8981\u6c42\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u53ef\u4ee5\u8bbf\u95ee\u5230\uff0c\u7f51\u7edc\u5730\u5740\u7684\u83b7\u53d6\u6709\u591a\u79cd\u65b9\u5f0f\uff1a\u53ef\u4ee5\u501f\u52a9\u5176\u4ed6\u5e73\u53f0\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5df1\u79df\u501f\u670d\u52a1\u5668\uff08\u5efa\u8bae\u81ea\u5df1\u79df\u4e00\u4e2a\u670d\u52a1\u5668\uff0c\u56e0\u4e3a\u6211\u4eec\u9700\u8981\u90e8\u7f72\u5e94\u7528\uff09\uff1b\u603b\u4e4b\uff0c\u4f60\u8981\u63d0\u4f9b\u51fa\u4e00\u4e2a\u516c\u7f51\u4e0a\u7684URL\uff1b<\/p>\n<p>2\u3001Tocken\uff08\u6807\u8bb0\uff09\uff1aTocken\u53ef\u4ee5\u968f\u4fbf\u586b\u5199\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5728\u8ba4\u8bc1\u7684\u65f6\u5019\u4f7f\u7528\uff1b<\/p>\n<p>3\u3001\u8ba4\u8bc1\u8fc7\u7a0b\uff1a\u9700\u8981\u5f00\u53d1\u8005\u8fdb\u884c\u7f16\u7a0b\uff0c\u6240\u4ee5\u8981\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u4e0a\u90e8\u7f72\u4e00\u4e2a\u5e94\u7528\uff08\u63d0\u4f9bURL\uff09\uff1b\u5f53\u516c\u7f51\u4e0a\u7684URL\u88ab\u5fae\u4fe1\u8bbf\u95ee\u65f6\uff0c\u5fae\u4fe1\u4f1a\u53d1\u9001\u8fc7\u6765\u4e00\u4e9b\u6570\u636e\uff0c\u4f60\u7684\u5e94\u7528\u8981\u628a\u5fae\u4fe1\u53d1\u9001\u8fc7\u6765\u7684\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\uff0c\u7136\u540e\u7528\u5bc6\u6587\u548csignature\u6bd4\u8f83\uff0c\u5982\u679c\u76f8\u540c\uff0c\u8fd4\u56deechostr\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u884c\u6821\u9a8c\uff0c\u5982\u679c\u6b63\u786e\uff0c\u90a3\u4e48\u606d\u559c\u4f60\uff0c\u4f60\u7684\u516c\u4f17\u8d26\u53f7\u6210\u4e3a\u6210\u4e3a\u5f00\u53d1\u8005\u8d26\u53f7\uff1b<\/p>\n<p>\u4e8c\u3001\u9a8c\u8bc1\u6d41\u7a0b\u56fe<\/p>\n<p>\u60a8\u5df2\u7ecf\u5411\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u63d0\u4f9b\u4e86 URL\uff08\u5f00\u53d1\u8005\u670d\u52a1\u5668\u7f51\u5740\u5740\uff09 \u548c Tocken\uff0c\u4e0b\u56fe\u662f\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8ba4\u8bc1\u6d41\u7a0b\uff1b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/932\/129\/441\/1490246262360845.png\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u516c\u4f17\u8d26\u53f7\u5f00\u53d1\uff1aURL \u548c Tocken\u4ecb\u7ecd\u63d2\u56fe\" alt=\"\u5fae\u4fe1\u516c\u4f17\u8d26\u53f7\u5f00\u53d1\uff1aURL \u548c Tocken\u4ecb\u7ecd\u63d2\u56fe\" \/><\/p>\n<p>\u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa\uff0c\u4e3b\u8981\u9a8c\u8bc1\u529f\u80fd\u662f\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fd9\u7aef\uff0c\u5176\u4e2d\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fd9\u7aef\u8fdb\u884ctocken\uff0ctimestamp\uff0cnonce\u52a0\u5bc6\u8ba4\u8bc1\uff08sha1\u52a0\u5bc6\uff09\u7684\u65f6\u5019\uff0ctocken\u662f\u5f00\u53d1\u8005\u63d0\u4f9b\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684\uff1b\u5982\u679c\u52a0\u5bc6\u7684\u7ed3\u679c\u548c \u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u63d0\u4f9b\u7684signature\u4e00\u6837\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u8fd4\u56deechostr\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\uff1b\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u884cechostr\u8ba4\u8bc1\uff0c\u5982\u679c\u901a\u8fc7\uff0c\u516c\u4f17\u8d26\u53f7\u5c31\u6210\u4e3a\u4e86\u5f00\u53d1\u8005<\/p>\n<p>\u4e09\u3001\u4ee3\u7801\u8bf4\u660e<\/p>\n<p>\u672c\u4eba\u5f00\u53d1\u7528\u7684\u662fpython\u8bed\u8a00\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5176\u4ed6\u8bed\u8a00\uff0c\u903b\u8f91\u7ed3\u6784\u7c7b\u4f3c\uff0c\u53ea\u662f\u5b9e\u73b0\u4e0d\u540c\uff1b<\/p>\n<pre>@csrf_exempt\r\ndef&nbsp;wx_valid(request):#\u63d0\u4f9b\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684url\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8bf7\u6c42url\u65f6\uff0c\u4f1a\u6267\u884c\u6b64\u65b9\u6cd5\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;'''\u5fae\u4fe1\u5f00\u53d1\u8005\u9a8c\u8bc1\uff0c\u662fGET\u8bf7\u6c42\uff1bGET&nbsp;\u548c&nbsp;POST&nbsp;\u533a\u5206\u662f\u8ba4\u8bc1\u8fd8\u662f\u53d1\u9001\u6d88\u606f\uff08\u53d1\u9001\u6d88\u606f\u7684\u65f6\u5019\u662fPOST\uff09'''\r\n&nbsp;&nbsp;&nbsp;&nbsp;if(request.method&nbsp;==&nbsp;'GET'):\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tocken='zainanjing6tocken'#\u63d0\u4f9b\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684tocken\uff0c\u53ef\u4ee5\u4fdd\u6301\u5728\u6570\u636e\u5e93\u3001\u6587\u4ef6\u6216\u8005\u76f4\u63a5\u786c\u7f16\u7801\u5230\u4ee3\u7801\u4e2d\uff1b\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;tocken:\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timestamp&nbsp;=&nbsp;request.GET['timestamp']\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nonce&nbsp;=&nbsp;request.GET['nonce']\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;signature&nbsp;=&nbsp;request.GET['signature']\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echostr&nbsp;=&nbsp;request.GET['echostr']\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arr&nbsp;=&nbsp;[tocken,timestamp,nonce]\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arr.sort()\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data&nbsp;=&nbsp;''\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;s&nbsp;in&nbsp;arr&nbsp;:\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data&nbsp;+=&nbsp;s\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sha1&nbsp;=&nbsp;hashlib.sha1()&nbsp;#\u6216hashlib.md5()&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sha1.update(data)\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_signature&nbsp;=&nbsp;sha1.hexdigest()&nbsp;#\u751f\u621040\u4f4d(sha1)\u621632\u4f4d(md5)\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;_signature&nbsp;==&nbsp;signature&nbsp;:\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;HttpResponse(echostr)#\u8fd4\u56de&nbsp;echostr\r\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;HttpResponse('error')#\u8fd4\u56de&nbsp;error<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5f00\u53d1\u8005\u9a8c\u8bc1URL\u548cTocken\u903b\u8f91\u6d41\u7a0b\u548c\u6e90\u7801\u4e86\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u8bf4\u4e00\u4e0b\u6574\u4f53\u7684\u64cd\u4f5c\u6d41\u7a0b\uff1b<\/p>\n<p>\u56db\u3001\u64cd\u4f5c\u8fc7\u7a0b<\/p>\n<p>1\u3001\u9996\u5148\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u4e0a\u90e8\u7f72\u5e94\u7528\uff0c\u63d0\u4f9b\u51faURL \u548c Tocken\uff0c\uff08\u6b64URL\u8981\u6c42\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u80fd\u591f\u8bbf\u95ee\u5230\uff09<\/p>\n<p>2\u3001\u628aURL \u548c Tocken \u6dfb\u52a0\u5230\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5f00\u53d1\u8005\u6a21\u5f0f\u4e2d\u540e\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5c31\u4f1a\u81ea\u52a8\u8bf7\u6c42URL\uff0c\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\uff08signature\u9a8c\u8bc1\uff09\uff0c\u5982\u679c\u9a8c\u8bc1\u901a\u8fc7\uff0c\u8fd4\u56deechostr\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0<\/p>\n<p>3\u3001\u5982\u679c\u6210\u529f\u6210\u4e3a\u4e86\u5f00\u53d1\u8005\u8d26\u53f7\uff0c\u5e76\u4e14\u516c\u4f17\u8d26\u53f7\u7684\u6a21\u5f0f\u8c03\u6574\u4e3a \u5f00\u53d1\u8005\u6a21\u5f0f \uff0c\u90a3\u4e48\u7528\u6237\u7ed9\u516c\u4f17\u8d26\u53f7\u53d1\u9001\u7684\u6d88\u606f\uff0c\u5c31\u4e0d\u662f\u7531\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u884c\u56de\u590d\u4e86\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u4f1a\u5c06\u6d88\u606f\u8f6c\u53d1\u7ed9\u5f00\u53d1\u8005\u670d\u52a1\u5668\uff0c\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fdb\u884c\u6d88\u606f\u56de\u590d<\/p>\n<p>\u81f3\u6b64\uff0cURL \u548c Tocken\u7684\u8ba4\u8bc1\u5c31\u7b97\u7ed3\u675f\u4e86\uff0c\u5982\u679c\u8ba4\u8bc1\u901a\u8fc7\u4e86\uff0c\u90a3\u4e48\u606d\u559c\uff0c\u4f60\u7684\u8d26\u53f7\u5df2\u7ecf\u662f\u5f00\u53d1\u8005\u8d26\u53f7\uff0c\u4e0b\u4e00\u6b65\u5fc5\u987b\u8981\u505a\u7684\u662f\u5f00\u53d1\u56de\u590d\u7528\u6237\u6d88\u606f\u7684\u529f\u80fd\uff0c\u4e0d\u7136\u7528\u6237\u63a5\u6536\u4e0d\u5230\u4efb\u4f55\u6d88\u606f\uff1b<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u516c\u4f17\u8d26\u53f7\u5f00\u53d1\uff1aURL \u548c Tocken\u4ecb\u7ecd\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001url \u548c tocken \u7b80\u4ecb 1\u3001\u60f3\u6210\u4e3a\u5f00\u53d1\u8005\u5fc5\u987b\u8981\u6709\u4e00\u4e2a\u516c\u7f51\u7684\u7f51\u7edc\u5730\u5740\uff08URL\uff09\uff0c\u8fd9\u4e2a\u7f51\u7edc\u5730\u5740\u8981\u6c42\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u53ef\u4ee5\u8bbf\u95ee\u5230\uff0c\u7f51\u7edc\u5730\u5740\u7684\u83b7\u53d6\u6709\u591a\u79cd\u65b9\u5f0f\uff1a\u53ef\u4ee5\u501f\u52a9\u5176\u4ed6\u5e73\u53f0\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5df1\u79df\u501f\u670d\u52a1\u5668\uff08\u5efa\u8bae\u81ea\u5df1\u79df\u4e00\u4e2a\u670d\u52a1\u5668\uff0c\u56e0\u4e3a\u6211\u4eec\u9700\u8981\u90e8\u7f72\u5e94\u7528\uff09\uff1b\u603b\u4e4b\uff0c\u4f60\u8981\u63d0\u4f9b\u51fa\u4e00\u4e2a\u516c\u7f51\u4e0a\u7684URL\uff1b 2\u3001Tocken\uff08\u6807\u8bb0\uff09\uff1aTocken\u53ef\u4ee5\u968f\u4fbf\u586b\u5199\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5728\u8ba4\u8bc1\u7684\u65f6\u5019\u4f7f\u7528\uff1b 3\u3001\u8ba4\u8bc1\u8fc7\u7a0b\uff1a\u9700\u8981\u5f00\u53d1\u8005\u8fdb\u884c\u7f16\u7a0b\uff0c\u6240\u4ee5\u8981\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u4e0a\u90e8\u7f72\u4e00\u4e2a\u5e94\u7528\uff08\u63d0\u4f9bURL\uff09\uff1b\u5f53\u516c\u7f51\u4e0a\u7684URL\u88ab\u5fae\u4fe1\u8bbf\u95ee\u65f6\uff0c\u5fae\u4fe1\u4f1a\u53d1\u9001\u8fc7\u6765\u4e00\u4e9b\u6570\u636e\uff0c\u4f60\u7684\u5e94\u7528\u8981\u628a\u5fae\u4fe1\u53d1\u9001\u8fc7\u6765\u7684\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\uff0c\u7136\u540e\u7528\u5bc6\u6587\u548csignature\u6bd4\u8f83\uff0c\u5982\u679c\u76f8\u540c\uff0c\u8fd4\u56deechostr\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u884c\u6821\u9a8c\uff0c\u5982\u679c\u6b63\u786e\uff0c\u90a3\u4e48\u606d\u559c\u4f60\uff0c\u4f60\u7684\u516c\u4f17\u8d26\u53f7\u6210\u4e3a\u6210\u4e3a\u5f00\u53d1\u8005\u8d26\u53f7\uff1b \u4e8c\u3001\u9a8c\u8bc1\u6d41\u7a0b\u56fe \u60a8\u5df2\u7ecf\u5411\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u63d0\u4f9b\u4e86 URL\uff08\u5f00\u53d1\u8005\u670d\u52a1\u5668\u7f51\u5740\u5740\uff09 \u548c Tocken\uff0c\u4e0b\u56fe\u662f\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8ba4\u8bc1\u6d41\u7a0b\uff1b \u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa\uff0c\u4e3b\u8981\u9a8c\u8bc1\u529f\u80fd\u662f\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fd9\u7aef\uff0c\u5176\u4e2d\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fd9\u7aef\u8fdb\u884ctocken\uff0ctimestamp\uff0cnonce\u52a0\u5bc6\u8ba4\u8bc1\uff08sha1\u52a0\u5bc6\uff09\u7684\u65f6\u5019\uff0ctocken\u662f\u5f00\u53d1\u8005\u63d0\u4f9b\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684\uff1b\u5982\u679c\u52a0\u5bc6\u7684\u7ed3\u679c\u548c \u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u63d0\u4f9b\u7684signature\u4e00\u6837\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u8fd4\u56deechostr\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\uff1b\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u884cechostr\u8ba4\u8bc1\uff0c\u5982\u679c\u901a\u8fc7\uff0c\u516c\u4f17\u8d26\u53f7\u5c31\u6210\u4e3a\u4e86\u5f00\u53d1\u8005 \u4e09\u3001\u4ee3\u7801\u8bf4\u660e \u672c\u4eba\u5f00\u53d1\u7528\u7684\u662fpython\u8bed\u8a00\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5176\u4ed6\u8bed\u8a00\uff0c\u903b\u8f91\u7ed3\u6784\u7c7b\u4f3c\uff0c\u53ea\u662f\u5b9e\u73b0\u4e0d\u540c\uff1b @csrf_exempt def&nbsp;wx_valid(request):#\u63d0\u4f9b\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684url\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8bf7\u6c42url\u65f6\uff0c\u4f1a\u6267\u884c\u6b64\u65b9\u6cd5 &nbsp;&nbsp;&nbsp;&nbsp;&#8221;&#8217;\u5fae\u4fe1\u5f00\u53d1\u8005\u9a8c\u8bc1\uff0c\u662fGET\u8bf7\u6c42\uff1bGET&nbsp;\u548c&nbsp;POST&nbsp;\u533a\u5206\u662f\u8ba4\u8bc1\u8fd8\u662f\u53d1\u9001\u6d88\u606f\uff08\u53d1\u9001\u6d88\u606f\u7684\u65f6\u5019\u662fPOST\uff09&#8221;&#8217; &nbsp;&nbsp;&nbsp;&nbsp;if(request.method&nbsp;==&nbsp;&#8216;GET&#8217;): &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tocken=&#8217;zainanjing6tocken&#8217;#\u63d0\u4f9b\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7684tocken\uff0c\u53ef\u4ee5\u4fdd\u6301\u5728\u6570\u636e\u5e93\u3001\u6587\u4ef6\u6216\u8005\u76f4\u63a5\u786c\u7f16\u7801\u5230\u4ee3\u7801\u4e2d\uff1b &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;tocken: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timestamp&nbsp;=&nbsp;request.GET[&#8216;timestamp&#8217;] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nonce&nbsp;=&nbsp;request.GET[&#8216;nonce&#8217;] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;signature&nbsp;=&nbsp;request.GET[&#8216;signature&#8217;] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echostr&nbsp;=&nbsp;request.GET[&#8216;echostr&#8217;] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arr&nbsp;=&nbsp;[tocken,timestamp,nonce] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arr.sort() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data&nbsp;=&nbsp;&#8221; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;s&nbsp;in&nbsp;arr&nbsp;: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data&nbsp;+=&nbsp;s &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sha1&nbsp;=&nbsp;hashlib.sha1()&nbsp;#\u6216hashlib.md5()&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sha1.update(data) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_signature&nbsp;=&nbsp;sha1.hexdigest()&nbsp;#\u751f\u621040\u4f4d(sha1)\u621632\u4f4d(md5)\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;_signature&nbsp;==&nbsp;signature&nbsp;: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;HttpResponse(echostr)#\u8fd4\u56de&nbsp;echostr &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;HttpResponse(&#8216;error&#8217;)#\u8fd4\u56de&nbsp;error \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u5f00\u53d1\u8005\u9a8c\u8bc1URL\u548cTocken\u903b\u8f91\u6d41\u7a0b\u548c\u6e90\u7801\u4e86\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u8bf4\u4e00\u4e0b\u6574\u4f53\u7684\u64cd\u4f5c\u6d41\u7a0b\uff1b \u56db\u3001\u64cd\u4f5c\u8fc7\u7a0b 1\u3001\u9996\u5148\u5728\u5f00\u53d1\u8005\u670d\u52a1\u5668\u4e0a\u90e8\u7f72\u5e94\u7528\uff0c\u63d0\u4f9b\u51faURL \u548c Tocken\uff0c\uff08\u6b64URL\u8981\u6c42\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u80fd\u591f\u8bbf\u95ee\u5230\uff09 2\u3001\u628aURL \u548c Tocken \u6dfb\u52a0\u5230\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5f00\u53d1\u8005\u6a21\u5f0f\u4e2d\u540e\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5c31\u4f1a\u81ea\u52a8\u8bf7\u6c42URL\uff0c\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\uff08signature\u9a8c\u8bc1\uff09\uff0c\u5982\u679c\u9a8c\u8bc1\u901a\u8fc7\uff0c\u8fd4\u56deechostr\u7ed9\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0 3\u3001\u5982\u679c\u6210\u529f\u6210\u4e3a\u4e86\u5f00\u53d1\u8005\u8d26\u53f7\uff0c\u5e76\u4e14\u516c\u4f17\u8d26\u53f7\u7684\u6a21\u5f0f\u8c03\u6574\u4e3a \u5f00\u53d1\u8005\u6a21\u5f0f \uff0c\u90a3\u4e48\u7528\u6237\u7ed9\u516c\u4f17\u8d26\u53f7\u53d1\u9001\u7684\u6d88\u606f\uff0c\u5c31\u4e0d\u662f\u7531\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u8fdb\u884c\u56de\u590d\u4e86\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u4f1a\u5c06\u6d88\u606f\u8f6c\u53d1\u7ed9\u5f00\u53d1\u8005\u670d\u52a1\u5668\uff0c\u5f00\u53d1\u8005\u670d\u52a1\u5668\u8fdb\u884c\u6d88\u606f\u56de\u590d \u81f3\u6b64\uff0cURL \u548c Tocken\u7684\u8ba4\u8bc1\u5c31\u7b97\u7ed3\u675f\u4e86\uff0c\u5982\u679c\u8ba4\u8bc1\u901a\u8fc7\u4e86\uff0c\u90a3\u4e48\u606d\u559c\uff0c\u4f60\u7684\u8d26\u53f7\u5df2\u7ecf\u662f\u5f00\u53d1\u8005\u8d26\u53f7\uff0c\u4e0b\u4e00\u6b65\u5fc5\u987b\u8981\u505a\u7684\u662f\u5f00\u53d1\u56de\u590d\u7528\u6237\u6d88\u606f\u7684\u529f\u80fd\uff0c\u4e0d\u7136\u7528\u6237\u63a5\u6536\u4e0d\u5230\u4efb\u4f55\u6d88\u606f\uff1b \u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u516c\u4f17\u8d26\u53f7\u5f00\u53d1\uff1aURL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-29283","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=29283"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29283\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}