{"id":29642,"date":"2024-11-25T11:11:35","date_gmt":"2024-11-25T03:11:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29642\/"},"modified":"2024-11-25T11:11:35","modified_gmt":"2024-11-25T03:11:35","slug":"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%b6%88%e6%81%af%e6%8e%a8%e9%80%81php%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%aa%8c%e8%af%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29642\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6d88\u606f\u63a8\u9001php\u670d\u52a1\u5668\u9a8c\u8bc1"},"content":{"rendered":"<p><span style=\"line-height: 1.76em\">\u8bbe\u7f6e\u9875\u9762\uff08\u201c\u8bbe\u7f6e\u201d&gt;&gt;\u201c\u5f00\u53d1\u8bbe\u7f6e\u201d\uff09\uff1a<\/span><\/p>\n<ol>\n<li>\n<p>\u8bbe\u7f6e\u670d\u52a1\u5668\u57df\u540d<br \/>\u6bd4\u5982\uff1ahttps:\/\/hosts.com<br \/>\u6ce8\u610fhttp\u548chttps\u534f\u8bae\u7684\u4e0d\u540c\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bbe\u7f6e\u6d88\u606f\u63a8\u9001<br \/>2.1 \u5728\u4f60\u7684\u670d\u52a1\u5668\u91cc\u6dfb\u52a0\u670d\u52a1\u5668test.php\uff0ctest.php\u63a5\u53e3\u5185\u5bb9\u4e3b\u8981\u662f\u901a\u8fc7token\u9a8c\u8bc1\u6d88\u606f\u662f\u5426\u4e3a\u5fae\u4fe1\u53d1\u6765\u7684\uff0c\u4ee3\u7801\u53c2\u7167\u5b98\u65b9\u7684\u4f8b\u5b50\uff1a<br \/>define(&#8220;TOKEN&#8221;,&#8221;xxxxx&#8221;);\/ \u540e\u53f0\u586b\u5199\u7684token<br \/>$wechatObj =  wechatAPI();<br \/>$wechatObj-&gt;isValid();<br \/> wechatAPI<br \/>{<br \/>public function isValid()\/\/\u9a8c\u8bc1\u5fae\u4fe1\u63a5\u53e3\uff0c\u5982\u679c\u786e\u8ba4\u662f\u5fae\u4fe1\u5c31\u8fd4\u56de\u5b83\u4f20\u6765\u7684str\u53c2\u6570<br \/>{<br \/> $echoStr = $_GET[&#8220;echostr&#8221;];<br \/> ($this-&gt;checkSignature()) {<br \/> &nbsp; echo $echoStr;<br \/> &nbsp; exit;<br \/> }<br \/>}<br \/>private function checkSignature() &nbsp; \/\/\u5b98\u65b9\u7684\u9a8c\u8bc1<br \/>{<br \/> $signature = $_GET[&#8220;signature&#8221;];<br \/> $stamp = $_GET[&#8220;timestamp&#8221;];<br \/> $nonce = $_GET[&#8220;nonce&#8221;];<br \/> $token = TOKEN;<br \/> $tmpArr = ($token, $timestamp, $nonce);<br \/>($tmpArr, SORT_);<br \/> $tmpStr = ( $tmpArr );<br \/> $tmpStr = ( $tmpStr );<br \/> if( $tmpStr == $signature ){<br \/> &nbsp;  true;<br \/> }{<br \/> &nbsp; return false;<br \/> }<br \/>}<br \/>};<br \/>2.2 \u8bbe\u7f6e\u5c0f\u7a0b\u5e8f\u540e\u53f0\u6d88\u606f\u63a8\u9001\u76f8\u5173\u4fe1\u606f<br \/>URL(\u670d\u52a1\u5668\u5730\u5740)\uff1ahttps:\/\/hosts.com\/xx\/test.php<br \/>Token: &nbsp;\u4efb\u610f\u7b26\u5408\u89c4\u8303\u7684\uff0c\u5982\u4e0a\u9762\u5b9a\u4e49\u7684&#8221;xxxxx&#8221;<br \/>EncodingAES(\u6d88\u606f\u52a0\u5bc6\u5bc6\u94a5)\uff1a\uff08\u968f\u673a\u751f\u6210\uff0c\u81ea\u5df1\u4fdd\u5b58\u5c31\u597d\u4e86\uff0c\u8fd9\u4e2a\u52a0\u89e3\u5bc6\u624d\u7528\uff09<br \/>\u6d88\u606f\u52a0\u5bc6\u65b9\u5f0f\uff1a\u6682\u65f6\u9009\u62e9\u660e\u6587\uff0c\u4e0d\u7528\u53bb\u8003\u8651\u52a0\u5bc6\u89e3\u5bc6\u7684\u95ee\u9898\u3002<br \/>\u6570\u636e\u683c\u5f0f\uff1a\u6839\u636e\u9700\u6c42\u9009\u62e9\u3002<br \/>\u63d0\u4ea4\uff0c\u5982\u679c\u6ca1\u6709\u95ee\u9898\u5c31\u4f1a\u6210\u529f\u4e86\u3002\uff08\u5982\u679c\u6709\u95ee\u9898\u4f60\u53ef\u4ee5\u7528\u5047\u7684\u6570\u636e\u901a\u8fc7\u6d4f\u89c8\u5668\u6d4b\u8bd5\uff09<\/p>\n<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6d88\u606f\u63a8\u9001php\u670d\u52a1\u5668\u9a8c\u8bc1\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>\u8bbe\u7f6e\u9875\u9762\uff08\u201c\u8bbe\u7f6e\u201d&gt;&gt;\u201c\u5f00\u53d1\u8bbe\u7f6e\u201d\uff09\uff1a \u8bbe\u7f6e\u670d\u52a1\u5668\u57df\u540d\u6bd4\u5982\uff1ahttps:\/\/hosts.com\u6ce8\u610fhttp\u548chttps\u534f\u8bae\u7684\u4e0d\u540c\u3002 \u8bbe\u7f6e\u6d88\u606f\u63a8\u90012.1 \u5728\u4f60\u7684\u670d\u52a1\u5668\u91cc\u6dfb\u52a0\u670d\u52a1\u5668test.php\uff0ctest.php\u63a5\u53e3\u5185\u5bb9\u4e3b\u8981\u662f\u901a\u8fc7token\u9a8c\u8bc1\u6d88\u606f\u662f\u5426\u4e3a\u5fae\u4fe1\u53d1\u6765\u7684\uff0c\u4ee3\u7801\u53c2\u7167\u5b98\u65b9\u7684\u4f8b\u5b50\uff1adefine(&#8220;TOKEN&#8221;,&#8221;xxxxx&#8221;);\/ \u540e\u53f0\u586b\u5199\u7684token$wechatObj = wechatAPI();$wechatObj-&gt;isValid(); wechatAPI{public function isValid()\/\/\u9a8c\u8bc1\u5fae\u4fe1\u63a5\u53e3\uff0c\u5982\u679c\u786e\u8ba4\u662f\u5fae\u4fe1\u5c31\u8fd4\u56de\u5b83\u4f20\u6765\u7684str\u53c2\u6570{ $echoStr = $_GET[&#8220;echostr&#8221;]; ($this-&gt;checkSignature()) { &nbsp; echo $echoStr; &nbsp; exit; }}private function checkSignature() &nbsp; \/\/\u5b98\u65b9\u7684\u9a8c\u8bc1{ $signature = $_GET[&#8220;signature&#8221;]; $stamp = $_GET[&#8220;timestamp&#8221;]; $nonce = $_GET[&#8220;nonce&#8221;]; $token = TOKEN; $tmpArr = ($token, $timestamp, $nonce);($tmpArr, SORT_); $tmpStr = ( $tmpArr ); $tmpStr = ( $tmpStr ); if( $tmpStr [&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-29642","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29642","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=29642"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29642\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}