{"id":29942,"date":"2024-11-25T13:50:40","date_gmt":"2024-11-25T05:50:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29942\/"},"modified":"2024-11-25T13:50:40","modified_gmt":"2024-11-25T05:50:40","slug":"%e5%be%ae%e4%bf%a1%e5%bc%80%e5%8f%91%e5%b8%a6%e5%8f%82%e6%95%b0%e4%ba%8c%e7%bb%b4%e7%a0%81%e7%9a%84%e5%ae%9e%e4%be%8b%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29942\/","title":{"rendered":"\u5fae\u4fe1\u5f00\u53d1\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u7684\u5b9e\u4f8b\u8be6\u89e3"},"content":{"rendered":"<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u6700\u8fd1\u505a\u5fae\u4fe1pc\u7aef\u7f51\u9875\u5fae\u4fe1\u76f8\u5173\u529f\u80fd\u7684\u5f00\u53d1\uff0c\u4ece\u4e00\u4e2a\u65b0\u624b\u7684\u89d2\u5ea6\u6765\u8bf4\uff0c\u5fae\u4fe1\u516c\u4f17\u53f7\u7684\u6587\u6863\u8fd8\u662f\u4e0d\u597d\u7406\u89e3\u7684\uff0c\u7f51\u4e0a\u627e\u7684\u5e16\u5b50\u5927\u90fd\u4e5f\u90fd\u57fa\u672c\u4e0a\u662f\u590d\u5236\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u4e0a\u7ed9\u7684\u6587\u6863\uff0c\u5f00\u53d1\u5fae\u4fe1\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u8fc7\u7a0b\u4e2d\u8fd8\u662f\u9047\u5230\u4e0d\u5c11\u5751\u7684\uff0c\u5728\u6b64\u628a\u6211\u7684\u5f00\u53d1\u8fc7\u7a0b\u6bd4\u8f83\u8be6\u7ec6\u7684\u8bb0\u5f55\u4e0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u6211\u672c\u6b21\u5f00\u53d1\u4f7f\u7528\u7684\u662f\u8ba4\u8bc1\u670d\u52a1\u53f7\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>1 \u63a5\u5165<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u9996\u5148\u8fdb\u5165\u5fae\u4fe1\u516c\u4f17\u53f7 -&gt; \u57fa\u672c\u914d\u7f6e&nbsp;<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u4e0b\u9762\u662f\u57fa\u672c\u914d\u7f6e\u7684\u9875\u9762\uff0c\u5728URL\u4e2d\u586b\u5199\u670d\u52a1\u5668\u5730\u5740\uff0c\u8fd9\u4e2a\u5730\u5740\u5c31\u662f\u63a5\u53d7\u5fae\u4fe1\u63a8\u9001\u4e8b\u4ef6\u7684\u4e00\u4e2a\u63a5\u53e3\uff0c\u6211\u662f\u4f7f\u7528thinkPHP\u6846\u67b6\u5f00\u53d1\u7684\u7a0b\u5e8f\uff0c\u5728\u5176\u4e2d\u4e00\u4e2aModule\uff08Decoration\uff09\u7684Action\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u7c7b\uff0c\u6bd4\u5982\u53eb\uff1a&nbsp;&nbsp;<span>WechatAction.class.php<\/span>&nbsp;&nbsp;\uff0c\u5728\u8be5Action\u4e2d\u65b0\u5efa\u4e00\u4e2apublic\u65b9\u6cd5\uff0c\u6bd4\u5982\u53eb\uff1a&nbsp;&nbsp;<span>URLRedirect()<\/span>&nbsp;&nbsp;\uff0c\u90a3\u4e48\u5728\u8fd9\u4e2aURL\u4e2d\u586b\u5199\u7684\u5c31\u662f&nbsp;&nbsp;<span>http:\/\/[IP]:[port]\/index.php\/Decoration\/Wechat\/UrlRedirect<\/span>&nbsp;&nbsp;,\u7136\u540e\u586b\u5199Token\uff0cToken\u968f\u610f\u586b\uff0cEncodingAESKey\u8981\u4e0d\u8981\u90fd\u884c\uff0c\u7136\u540e\u70b9\u51fb\u786e\u8ba4\uff0c\u5fae\u4fe1\u4f1a\u5f80\u8fd9\u4e2aURL\u4e0a\u53d1\u9001\u4e00\u4e2aget\u8bf7\u6c42\uff0c\u91cc\u9762\u5305\u542b\u5f88\u591a\u53c2\u6570\uff0c\u5176\u4e2d\u5927\u90e8\u5206\u90fd\u662f\u8ba9\u6211\u4eec\u81ea\u5df1\u6838\u5bf9\u8fd9\u6b21\u8bbf\u95ee\u662f\u4e0d\u662f\u5fae\u4fe1\u670d\u52a1\u5668\u8bf7\u6c42\u7684\uff0c\u6211\u81ea\u5df1\u6ca1\u6709\u9a8c\u8bc1\uff0c\u4ed6\u7684\u8981\u6c42\u662f\u5982\u679c\u6211\u4eec\u6838\u5bf9\u6210\u529f\uff0c\u5373\u539f\u6837\u8fd4\u56deget\u8bf7\u6c42\u4e2d\u7684\u4e00\u4e2a\u53c2\u6570echostr\uff0c\u8fd9\u91cc\u7684\u8fd4\u56de\u4e0d\u662freturn\uff0c\u4e5f\u4e0d\u662fajaxReturn\uff0c\u800c\u4f7f\u7528echo\uff0c\u5982\u679c\u7528thinkPHP\u5f00\u53d1\u7684\u8bdd\uff0c\u76f4\u63a5\u4f7f\u7528&nbsp;&nbsp;<span>echo I(&#8216;echostr&#8217;);<\/span>&nbsp;&nbsp;\u5373\u53ef\u3002\u7136\u540e\u63a5\u53e3\u5373\u9a8c\u8bc1\u6210\u529f\u4e86\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/474529\/201607\/474529-20160731001630044-1124025958.png\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u7684\u5b9e\u4f8b\u8be6\u89e3\u63d2\u56fe\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u7684\u5b9e\u4f8b\u8be6\u89e3\u63d2\u56fe\" \/><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">&nbsp;<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>2 \u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u7684\u4f5c\u7528<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5fae\u4fe1\u7684\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u4e34\u65f6\u4e8c\u7ef4\u7801\uff0c\u4e00\u79cd\u662f\u6c38\u4e45\u4e8c\u7ef4\u7801\uff0c\u4f46\u662f\u6c38\u4e45\u4e8c\u7ef4\u7801\u7684\u751f\u6210\u662f\u6709\u4e2a\u6570\u9650\u5236\u7684\uff0c\u6211\u8fd9\u6b21\u8981\u5b9e\u73b0\u7684\u529f\u80fd\u662f\u7528\u6237\u672a\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\u5728\u7f51\u7ad9\u4e0a\u4f7f\u7528\u4ea7\u54c1\uff0c\u6bd4\u5982\u83b7\u5f97\u67d0\u5546\u54c1\u7684\u8be6\u7ec6\u62a5\u4ef7\uff0c\u4f46\u662f\u53c8\u4e0d\u60f3\u6ce8\u518c\uff0c\u7136\u800c\u53c8\u60f3\u4fdd\u5b58\u8fd9\u4e2a\u62a5\u4ef7\u5355\uff0c\u8fd9\u4e2a\u65f6\u5019\u7f51\u9875\u53ef\u4ee5\u751f\u6210\u4e00\u5f20\u4e8c\u7ef4\u7801\uff0c\u7528\u6237\u53ea\u8981\u7528\u5fae\u4fe1\u626b\u4e00\u626b\u8fd9\u4e2a\u4e8c\u7ef4\u7801\uff0c\u5b98\u65b9\u516c\u4f17\u53f7\u5c31\u4f1a\u7ed9\u8fd9\u4e2a\u7528\u6237\u53d1\u9001\u4e00\u5929\u56fe\u6587\u6d88\u606f\uff0c\u56fe\u6587\u6d88\u606f\u70b9\u5f00\u540e\u5c31\u662f\u7528\u6237\u521a\u521a\u83b7\u5f97\u7684\u62a5\u4ef7\u5355\uff0c\u800c\u4e14\u53ef\u4ee5\u968f\u65f6\u70b9\u51fb\u67e5\u770b\u5e76\u4e14\u5206\u4eab\u7ed9\u670b\u53cb\u8fdb\u884c\u6bd4\u4ef7\u3002\u6240\u4ee5\u4e34\u65f6\u4e8c\u7ef4\u7801\u5373\u53ef\u6b63\u5e38\u4f7f\u7528\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u4e0a\u9762\u662f\u6211\u662f\u600e\u4e48\u4f7f\u7528\u7684\uff0c\u4e0b\u9762\u4ecb\u7ecd\u4e00\u4e0b\u6574\u4e2a\u4ea4\u4e92\u7684\u6d41\u7a0b\uff1a<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5f53\u7528\u6237\u626b\u63cf\u8fd9\u4e2a\u4e8c\u7ef4\u7801\uff0c\u5982\u679c\u7528\u6237\u5173\u6ce8\u4e86\u516c\u4f17\u53f7\uff0c\u7528\u6237\u4f1a\u76f4\u63a5\u8fdb\u5165\u4e0e\u516c\u4f17\u53f7\u7684\u4f1a\u8bdd\u9875\u9762\uff0c\u5fae\u4fe1\u670d\u52a1\u5668\u4f1a\u7ed9\u6211\u4eec\u5728\u4e0a\u4e00\u6b65\u8bbe\u7f6e\u7684\u670d\u52a1\u5668URL\u4e2d\u63a8\u9001\u4e00\u6761\u6d88\u606f\uff0c\u5176\u4e2d\u53ef\u4ee5\u643a\u5e26\u4e00\u4e2a\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u53c2\u6570\u3002\u5982\u679c\u7528\u6237\u672a\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5219\u7528\u6237\u9996\u5148\u4f1a\u8df3\u8f6c\u5230\u516c\u4f17\u53f7\u5173\u6ce8\u9875\u9762\uff0c\u7528\u6237\u70b9\u51fb\u5173\u6ce8\u540e\uff0c\u4f1a\u76f4\u63a5\u8fdb\u5165\u516c\u4f17\u53f7\u7684\u4f1a\u8bdd\u9875\u9762\uff0c\u5fae\u4fe1\u670d\u52a1\u5668\u8fd9\u65f6\u4e5f\u4f1a\u7ed9\u6211\u4eec\u8bbe\u7f6e\u7684URL\u63a8\u9001\u4e00\u4e2a\u4e8b\u4ef6\u6d88\u606f\uff0c\u643a\u5e26\u6211\u4eec\u81ea\u5b9a\u4e49\u53c2\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u53c2\u6570\u548c\u4e8b\u4ef6\u7c7b\u578b\u505a\u63a7\u5236\u4e0b\u4e00\u6b65\u52a8\u4f5c\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">&nbsp;<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3 \u5177\u4f53\u5f00\u53d1\u8fc7\u7a0b<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3.1 \u83b7\u53d6access_token<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u8fd9\u4e2aaccess_token\u662f\u6211\u4eec\u7a0b\u5e8f\u8c03\u7528\u5fae\u4fe1\u63a5\u53e3\u7684\u51ed\u8bc1\uff0c\u76ee\u524d\u7684\u6709\u6548\u671f\u662f7200\u79d2\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5b9a\u65f6\u66f4\u65b0access_token\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u83b7\u5f97\u65b9\u6cd5\uff1a<\/span><\/p>\n<pre>\u65b9\u6cd5&nbsp;\uff1a&nbsp;GET\r\nurl&nbsp;\uff1ahttps:\/\/api.weixin.qq.com\/cgi-bin\/token?grant_type=client_credential&amp;amp;appid=APPID&amp;amp;secret=APPSECRET<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5176\u4e2d\u7684\u53c2\u6570APPID\u548cAPPSECRET\u662f\u6211\u4eec\u516c\u4f17\u53f7\u7684APPID\u548cAPPSECRET\uff0c\u5728\u5fae\u4fe1\u516c\u4f17\u53f7 -&gt; \u57fa\u672c\u914d\u7f6e\u4e2d\u53ef\u4ee5\u67e5\u5230\uff0c\u8c03\u7528\u6210\u529f\u4f1a\u8fd4\u56de\u5982\u4e0bJSON\u6570\u636e\uff1a<\/span><\/p>\n<pre>{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5176\u4e2daccess_token\u5c31\u662f\u8c03\u7528\u63a5\u53e3\u51ed\u8bc1\uff0cexpire_in\u662ftoken\u6709\u6548\u65f6\u95f4\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u6211\u672c\u4eba\u662f\u628aaccess_token\u5b58\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u540c\u65f6\u4fdd\u5b58\u8fc7\u671f\u65f6\u95f4\uff0c\u7136\u540e\u5c01\u88c5\u516c\u7528\u51fd\u6570&nbsp;&nbsp;<span>getWechatAccessToken()<\/span>&nbsp;&nbsp;\uff0c\u6bcf\u6b21\u5148\u68c0\u67e5access_token\u662f\u5426\u8fc7\u671f\uff0c\u5982\u679c\u8fc7\u671f\u5219\u91cd\u65b0\u83b7\u53d6\uff0c\u5426\u5219\u76f4\u63a5\u4f7f\u7528\u6570\u636e\u5e93\u4fdd\u5b58\u7684access_token\u5373\u53ef\uff0c\u6211\u5fd8\u4e86\u5728\u54ea\u513f\u770b\u52a0\u8fc7\uff0c\u8fd9\u4e2aaccess_token\u6bcf\u5929\u7684\u83b7\u53d6\u6b21\u6570\u5e94\u8be5\u662f\u6709\u9650\u5236\u7684\u3002\u4e0b\u9762\u662f&nbsp;&nbsp;<span>getWechatAccessToken()<\/span>&nbsp;&nbsp; \u7684\u5177\u4f53\u5b9e\u73b0\uff1a<\/span><\/p>\n<pre>&nbsp;1&nbsp;\/\/\u83b7\u53d6access_token\r\n&nbsp;2&nbsp;function&nbsp;getWechatAccessToken(){&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wechatInfo&nbsp;=&nbsp;M('wechat_info')-&amp;gt;select();&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wechatInfo&nbsp;=&nbsp;array_reduce($wechatInfo,&nbsp;create_function('$result,&nbsp;$v',&nbsp;'$result[$v[\"conf_name\"]]&nbsp;=&nbsp;$v;return&nbsp;$result;'));&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$expireTime&nbsp;=&nbsp;$wechatInfo['PUBLIC_WECHAT_ACCESSTOKEN_EXPIRES']['conf_value'];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u524d\u9762\u4e0d\u7528\u7ba1\uff0c\u662f\u6211\u6570\u636e\u5e93\u76f8\u5e94\u8bbe\u7f6e\r\n&nbsp;6&nbsp;\r\n&nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(time()&nbsp;where(array('conf_name'&nbsp;=&amp;gt;&nbsp;'PUBLIC_WECHAT_ACCESSTOKEN'))-&amp;gt;save(array('conf_value'&nbsp;=&amp;gt;&nbsp;$result['access_token']));19&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;M('wechat_info')-&amp;gt;where(array('conf_name'&nbsp;=&amp;gt;&nbsp;'PUBLIC_WECHAT_ACCESSTOKEN_EXPIRES'))-&amp;gt;save(array('conf_value'&nbsp;=&amp;gt;&nbsp;time()+$result['expires_in']-200));20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$result['access_token'];21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}23&nbsp;}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    <\/p>\n<pre>C('WECHAT_PUBLIC_GET_ACCESS_TOKEN')&nbsp;=&nbsp;https:\/\/api.weixin.qq.com\/cgi-bin\/token?grant_type=client_credential&amp;amp;appid=APPID&amp;amp;secret=APPSECRET<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5c01\u88c5\u597d\u8fd9\u4e2a\u4e4b\u540e\uff0c\u6211\u4eec\u6bcf\u6b21\u5c31\u53ef\u4ee5\u5b89\u5fc3\u7684\u4f7f\u7528\u4e86\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3.2 \u521b\u5efa\u4e34\u65f6\u4e8c\u7ef4\u7801<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3.2.1 \u83b7\u53d6ticket<\/strong><\/span><\/p>\n<pre>\u3000\u3000\u3000\u3000&nbsp;&nbsp;\u8bf7\u6c42\u65b9\u5f0f\uff1a&nbsp;POST\r\n\u3000\u3000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u63a5\u53e3\uff1ahttps:\/\/api.weixin.qq.com\/cgi-bin\/qrcode\/create?access_token=TOKEN\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;POST\u6570\u636e\uff1a&nbsp;{\"expire_seconds\":&nbsp;604800,&nbsp;\"action_name\":&nbsp;\"QR_SCENE\",&nbsp;\"action_info\":&nbsp;{\"scene\":&nbsp;{\"scene_id\":&nbsp;123}}}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u63a5\u53e3URL\u4e2d\u7684TOKEN\u5373\u6211\u4eec\u57283.1\u4e2d\u83b7\u53d6\u7684access_token\uff0cpost\u6570\u636e\u4e2dexpire_seconds\u662f\u4e8c\u7ef4\u7801\u7684\u6709\u6548\u65f6\u95f4\uff0c\u6700\u591a\u4e3a30\u5929\uff0caction_name\u4e34\u65f6\u4e8c\u7ef4\u7801\u7684\u8bdd\u56fa\u5b9a\u5c31\u662fQR_SCENE\uff0cscene_id\u5373\u6211\u4eec\u81ea\u5b9a\u4e49\u53c2\u6570\uff0c\u662f\u4e2a32\u4f4d\u975e0\u6574\u6570\uff0c\u6211\u5728\u5e94\u7528\u4e2d\u628a\u5b83\u8bbe\u4e3a\u8ba2\u5355\u7684ID\uff0c\u5fae\u4fe1\u670d\u52a1\u5668\u63a8\u9001\u4e8b\u4ef6\u7684\u65f6\u5019\u4f1a\u628a\u8fd9\u4e2a\u503c\u8fd4\u56de\u7ed9\u6211\u4eec\u8bbe\u7f6e\u7684\u63a5\u53e3\u4e2d\uff0c\u7136\u540e\u6211\u4f1a\u6839\u636e\u8fd9\u4e2a\u503c\u53bb\u62ff\u76f8\u5e94\u7684\u8ba2\u5355\u6570\u636e\u5c55\u793a\u5728\u7f51\u9875\u4e0a\uff0c\u8fd9\u662f\u540e\u8bdd\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u4e0b\u9762\u662f\u5c01\u88c5\u7684\u751f\u6210\u4e34\u65f6\u4e8c\u7ef4\u7801\u7684\u65b9\u6cd5\uff1a<\/span><\/p>\n<pre>\/\/\u521b\u5efa\u4e34\u65f6\u4e8c\u7ef4\u7801function&nbsp;getTemporaryQrcode($orderId){&nbsp;&nbsp;&nbsp;&nbsp;$accessToken&nbsp;=&nbsp;getWechatAccessToken();&nbsp;&nbsp;&nbsp;&nbsp;$url&nbsp;=&nbsp;str_replace(\"##TOKEN##\",&nbsp;$accessToken,&nbsp;C('WECHAT_PUBLIC_GET_TEMPORARY_TICKET'));&nbsp;&nbsp;&nbsp;&nbsp;$qrcode&nbsp;=&nbsp;'{\"expire_seconds\":&nbsp;1800,&nbsp;\"action_name\":&nbsp;\"QR_SCENE\",&nbsp;\"action_info\":&nbsp;{\"scene\":&nbsp;{\"scene_id\":&nbsp;'.$orderId.'}}}';&nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;api_notice_increment($url,&nbsp;$qrcode);&nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;json_decode($result,&nbsp;true);&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;urldecode($result['url']);\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5176\u4e2d\u7684\u65b9\u6cd5 &nbsp;<span>api_notice_increment()<\/span>&nbsp;&nbsp;\u662f\u6211\u5c01\u88c5\u7684\u4e00\u4e2aPOST\u65b9\u6cd5\u51fd\u6570\uff0c\u6211\u8bd5\u8fc7\u5f88\u591aPOST\u7684\u65b9\u6cd5\uff0c\u53ef\u80fd\u7531\u4e8e\u5fae\u4fe1\u63a5\u53e3\u5bf9POST\u65b9\u6cd5\u548c\u53c2\u6570\u7684\u9650\u5236\u6bd4\u8f83\u4e25\u683c\uff0c\u8fd9\u4e2a\u6d6a\u8d39\u4e86\u597d\u4e45\u65f6\u95f4\uff0c\u6700\u540e\u5728\u7f51\u4e0a\u627e\u5230\u4e86\u4e00\u4e2a\u53ef\u4ee5\u4f7f\u7528\u7684\u5c01\u88c5\u597d\u7684POST\u65b9\u6cd5\uff0c\u5efa\u8bae\u5927\u5bb6\u5148\u81ea\u5df1\u8bd5\u8bd5\uff0c\u5982\u679c\u5fae\u4fe1\u8fd4\u56de\u9519\u8bef\u5417\uff0c\u5c31\u7528\u8fd9\u4e2a\u5427\uff0c\u8d77\u7801\u6211\u6d4b\u8bd5\u5fae\u4fe1\u8fd9\u4e2a\u63a5\u53e3\u7684\u65f6\u5019\u7528postman\u6d4b\u8bd5\u8fd4\u56de\u7684\u90fd\u662f\u9519\u8bef\uff0c\u800c\u4e14\u4e00\u5b9a\u8981\u7528JSON\u5b57\u7b26\u4e32\uff0c\u4e00\u5b9a\u8981\u662f\u975e\u5e38\u4e25\u683c\u7684JSON\u5b57\u7b26\u4e32\u3002\u4e0b\u9762\u662f\u8fd9\u4e2a\u65b9\u6cd5\uff1a<\/span><\/p>\n<pre>function&nbsp;api_notice_increment($url,&nbsp;$data){&nbsp;&nbsp;&nbsp;&nbsp;$ch&nbsp;=&nbsp;curl_init();&nbsp;&nbsp;&nbsp;&nbsp;$header&nbsp;=&nbsp;\"Accept-Charset:&nbsp;utf-8\";\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_URL,&nbsp;$url);\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_CUSTOMREQUEST,&nbsp;\"POST\");\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_SSL_VERIFYPEER,&nbsp;FALSE);\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_SSL_VERIFYHOST,&nbsp;FALSE);\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_HTTPHEADER,&nbsp;$header);\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_USERAGENT,&nbsp;'Mozilla\/5.0&nbsp;(compatible;&nbsp;MSIE&nbsp;5.01;&nbsp;Windows&nbsp;NT&nbsp;5.0)');\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_FOLLOWLOCATION,&nbsp;1);\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_AUTOREFERER,&nbsp;1);\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_POSTFIELDS,&nbsp;$data);\r\n&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch,&nbsp;CURLOPT_RETURNTRANSFER,&nbsp;true);&nbsp;&nbsp;&nbsp;&nbsp;$tmpInfo&nbsp;=&nbsp;curl_exec($ch);&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(curl_errno($ch))&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_close(&nbsp;$ch&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$ch;\r\n&nbsp;&nbsp;&nbsp;&nbsp;}else{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_close(&nbsp;$ch&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$tmpInfo;\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">&nbsp;<span>getTemporaryQrcode() <\/span>&nbsp;\u4e2d\u6709\u4e00\u4e2a\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u53c2\u6570\u7ed9\u5927\u5bb6\u770b\u4e0b\uff0c\u5176\u5b9e\u5c31\u662f\u5fae\u4fe1\u63a5\u53e3\u94fe\u63a5\uff1a<\/span><\/p>\n<pre>C('WECHAT_PUBLIC_GET_TEMPORARY_TICKET')&nbsp;=&nbsp;https:\/\/api.weixin.qq.com\/cgi-bin\/qrcode\/create?access_token=##TOKEN##<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u8fd9\u4e2a\u63a5\u53e3\u7684\u8fd4\u56de\u503c\u662f\uff1a<\/span><\/p>\n<pre>{\"ticket\":\"gQH47joAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL2taZ2Z3TVRtNzJXV1Brb3ZhYmJJAAIEZ23sUwMEmm3sUw==\",\"expire_seconds\":60,\"url\":\"http:\/\/weixin.qq.com\/q\/kZgfwMTm72WWPkovabbI\"}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5176\u4e2dticket\u662f\u8ba9\u6211\u4eec\u7528\u6765\u8fdb\u884c\u4e0b\u4e00\u6b65\u8c03\u7528\u7684\u51ed\u8bc1\uff0cexpire_seconds\u662f\u4e8c\u7ef4\u7801\u7684\u6709\u6548\u671f\uff0curl\u662f\u6211\u4eec\u751f\u6210\u7684\u4e8c\u7ef4\u7801\u626b\u63cf\u540e\u6253\u5f00\u7684\u94fe\u63a5\u3002\u6240\u4ee5\u5982\u679c\u6211\u4eec\u81ea\u5df1\u5b9e\u73b0\u4e86\u751f\u6210\u4e8c\u7ef4\u7801\u7684\u65b9\u6cd5\uff0c\u5c31\u4e0d\u7528\u518d\u8fdb\u884c\u4e0b\u4e00\u6b65\u8c03\u7528\uff0c\u6211\u672c\u4eba\u5373\u5728\u8fd9\u4e00\u6b65\u5c31\u505c\u6b62\u4e86\uff0c\u76f4\u63a5\u8fd4\u56deurl\u7684\u503c\uff0c\u7136\u540e\u5229\u7528\u8fd9\u4e2aurl\u7684\u503c\u751f\u6210\u4e8c\u7ef4\u7801\u5b58\u5728\u672c\u5730\u5373\u53ef\u3002PHP\u751f\u6210\u4e8c\u7ef4\u7801\u53ef\u4ee5\u4f7f\u7528phpqrcode\uff0c\u633a\u597d\u7528\u7684\u3002\u4e0b\u4e00\u6b65\u4e5f\u5927\u81f4\u63d0\u4e00\u4e0b\uff1a<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3.2.2 \u83b7\u53d6\u4e8c\u7ef4\u7801\u5730\u5740<\/strong><\/span><\/p>\n<pre>\u3000\u3000&nbsp;\u8bf7\u6c42\u65b9\u5f0f\uff1a&nbsp;GET\r\n\u3000\u3000&nbsp;\u63a5\u53e3\uff1ahttps:\/\/mp.weixin.qq.com\/cgi-bin\/showqrcode?ticket=TICKET<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">&nbsp;<\/span><span style=\"color: #000000;font-size: 15px\">\u3000\u8fd9\u4e2a\u63a5\u53e3\u7684\u8fd4\u56de\u503c\u662f\u4e00\u5f20\u56fe\u7247\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c55\u793a\u6216\u8005\u4e0b\u8f7d\uff0c\u6211\u4eec\u6709\u5177\u4f53\u4f7f\u7528\u8fc7\uff0c\u6240\u4ee5\u4e5f\u4e0d\u77e5\u9053\u5e94\u8be5\u600e\u4e48\u5c55\u793a\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3.3 \u7528\u6237\u626b\u63cf\u4e8c\u7ef4\u7801\u4e4b\u540e\u53d1\u751f\u7684\u4e8b\u60c5<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3.3.1 \u626b\u63cf\u540e\u53d1\u751f\u4e86\u4ec0\u4e48<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u4e0a\u9762\u63d0\u5230\u4e86\uff0c\u7528\u6237\u626b\u63cf\u6211\u4eec\u751f\u6210\u7684\u4e34\u65f6\u4e8c\u7ef4\u7801\uff0c\u5982\u679c\u7528\u6237\u672a\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5219\u9996\u5148\u4f1a\u8df3\u8f6c\u5230\u516c\u4f17\u53f7\u7684\u5173\u6ce8\u9875\u9762\uff0c\u70b9\u51fb\u5173\u6ce8\u540e\uff0c\u4f1a\u8fdb\u5165\u516c\u4f17\u53f7\u7684\u4f1a\u8bdd\u9875\u9762\uff0c\u540c\u65f6\u4f1a\u7ed9\u6211\u4eec\u8bbe\u7f6e\u7684\u63a5\u53e3\u63a8\u9001\u4e00\u4e2a\u4e8b\u4ef6\u3002\u5982\u679c\u7528\u6237\u5df2\u7ecf\u5173\u6ce8\u4e86\uff0c\u7528\u6237\u5fae\u4fe1\u4f1a\u76f4\u63a5\u8df3\u8f6c\u5230\u516c\u4f17\u53f7\u4f1a\u8bdd\u9875\u9762\uff0c\u7136\u540e\u5fae\u4fe1\u670d\u52a1\u5668\u4f1a\u7ed9\u6211\u4eec\u8bbe\u7f6e\u7684\u63a5\u53e3\u63a8\u9001\u4e00\u4e2a\u4e8b\u4ef6\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u7528\u6237\u5173\u6ce8\u4e0e\u5426\u5fae\u4fe1\u670d\u52a1\u5668\u7ed9\u6211\u4eec\u63a8\u9001\u7684\u4e8b\u4ef6\u662f\u5dee\u4e0d\u591a\u7684\uff0c\u53ea\u662f\u65b0\u5173\u6ce8\u7528\u6237\u63a8\u9001\u7684\u4e8b\u4ef6\u4e2dscene_id\u524d\u9762\u4f1a\u52a0\u4e00\u4e2a\u524d\u7f00\u3002\u4e0b\u9762\u662f\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u6587\u6863\u7684\u8bf4\u660e\uff1a<\/span><\/p>\n<pre>\u3000\u7528\u6237\u672a\u5173\u6ce8\u65f6\uff0c\u8fdb\u884c\u5173\u6ce8\u540e\u7684\u4e8b\u4ef6\u63a8\u9001<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    <\/p>\n<pre>&lt;xml&gt;&lt;tousername&gt;&lt;\/tousername&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u5f00\u53d1\u8005\u5fae\u4fe1\u53f7&lt;fromusername&gt;&lt;\/fromusername&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u53d1\u9001\u8005\u8d26\u53f7\uff08openid\uff09&lt;createtime&gt;123456789&lt;\/createtime&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u6d88\u606f\u521b\u5efa\u65f6\u95f4\uff08\u6574\u578b\uff09&lt;msgtype&gt;&lt;\/msgtype&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u6d88\u606f\u7c7b\u578b&nbsp;event&lt;event&gt;&lt;\/event&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u4e8b\u4ef6\u7c7b\u578b\uff08subscribe\uff09&lt;eventkey&gt;&lt;\/eventkey&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u4e8b\u4ef6KEY\u503c\uff0cqrscene_\u4e3a\u524d\u7f00\uff0c\u540e\u9762\u4e3a\u4e8c\u7ef4\u7801\u53c2\u6570\u503c&lt;ticket&gt;&lt;\/ticket&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u4e8c\u7ef4\u7801ticke\u503c\uff0c\u53ef\u4ee5\u7528\u6765\u6362\u53d6\u4e8c\u7ef4\u7801\u56fe\u7247&lt;\/xml&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">&nbsp;\u3000\u3000\u7528\u6237\u5df2\u5173\u6ce8\u65f6\u7684\u4e8b\u4ef6\u63a8\u9001<\/span><\/p>\n<pre>&nbsp;&lt;xml&gt;&lt;tousername&gt;&lt;\/tousername&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u5f00\u53d1\u8005\u5fae\u4fe1\u53f7&lt;fromusername&gt;&lt;\/fromusername&gt;\u3000\u3000\u3000\u3000&nbsp;\/\/\u53d1\u9001\u8005\u8d26\u53f7\uff08openid\uff09&lt;createtime&gt;123456789&lt;\/createtime&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u6d88\u606f\u521b\u5efa\u65f6\u95f4&lt;msgtype&gt;&lt;\/msgtype&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u6d88\u606f\u7c7b\u578bevent&lt;event&gt;&lt;\/event&gt;\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000&nbsp;\/\/\u4e8b\u4ef6\u7c7b\u578b&nbsp;event&lt;eventkey&gt;&lt;\/eventkey&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u4e8b\u4ef6key\u503c\uff0c\u662f\u4e00\u4e2a32\u4f4d\u65e0\u7b26\u53f7\u6574\u6570\uff0c\u5373\u521b\u5efa\u4e8c\u7ef4\u7801\u65f6\u7684\u4e8c\u7ef4\u7801scene_id&lt;ticket&gt;&lt;\/ticket&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u4e8c\u7ef4\u7801\u7684ticke\uff0c\u53ef\u4ee5\u7528\u6765\u6362\u53d6\u4e8c\u7ef4\u7801\u56fe\u7247&lt;\/xml&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\"><strong>3.3.2 \u6211\u4eec\u8981\u505a\u4e9b\u4ec0\u4e48<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u6211\u4eec\u9700\u8981\u5728\u81ea\u5df1\u586b\u5199\u7684URL\u63a5\u53e3\u4e2d\u63a5\u6536\u8fd9\u4e2a\u4e8b\u4ef6\uff0c\u7136\u540e\u62ff\u5230\u6211\u4eec\u9700\u8981\u7684\u4e1c\u897f\u505a\u6211\u4eec\u60f3\u5e72\u7684\u4e8b\u513f\u3002\u56e0\u4e3a\u6211\u8981\u5b9e\u73b0\u7684\u529f\u80fd\u6bd4\u8f83\u7b80\u5355\uff0c\u53ea\u9700\u8981\u62ff\u5230scene_id\u5373\u53ef\uff0c\u56e0\u4e3a\u8fd9\u662f\u6211\u8981\u5c55\u793a\u7ed9\u7528\u6237\u770b\u7684\u8ba2\u5355\u6570\u636e\u3002\u4e0b\u9762\u662f\u6211\u5199\u7684\u63a5\u6536\u548c\u5904\u7406\u90e8\u5206\uff0c\u6bd4\u8f83\u7b80\u5355\uff0c\u4e3b\u8981\u770b\u4e00\u4e0b\u5e94\u8be5\u600e\u4e48\u63a5\u6536\u5fae\u4fe1\u63a8\u9001\u7684\u4e8b\u4ef6\uff1a<\/span><\/p>\n<pre>public&nbsp;function&nbsp;urlRedirect(){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$postStr&nbsp;=&nbsp;$GLOBALS[\"HTTP_RAW_POST_DATA\"];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$postObj&nbsp;=&nbsp;simplexml_load_string($postStr,&nbsp;'SimpleXMLElement',&nbsp;LIBXML_NOCDATA);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fromUsername&nbsp;=&nbsp;(string)$postObj-&amp;gt;FromUserName;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$EventKey&nbsp;=&nbsp;trim((string)$postObj-&amp;gt;EventKey);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$keyArray&nbsp;=&nbsp;explode(\"_\",&nbsp;$EventKey);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(count($keyArray)&nbsp;==&nbsp;1){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u5df2\u5173\u6ce8\u8005\u626b\u63cf\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;sendMessage($fromUsername,&nbsp;$EventKey);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\/\/\u672a\u5173\u6ce8\u8005\u5173\u6ce8\u540e\u63a8\u9001\u4e8b\u4ef6\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&amp;gt;sendMessage($fromUsername,&nbsp;$keyArray[1]);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u6211\u6ca1\u6709\u4f7f\u7528\u5176\u4ed6\u53c2\u6570\uff0c\u53ea\u662f\u6839\u636e\u4e0d\u540c\u7684\u63a8\u9001\u4e8b\u4ef6\u62ff\u5230\u6211\u60f3\u8981\u7684\u8ba2\u5355ID\uff0c\u7136\u540e\u8fd9\u65f6\u5019\u5176\u5b9e\u76f8\u5f53\u4e8e\u4f60\u5728\u8fd9\u91cc\u7528\u516c\u4f17\u53f7\u7684\u5ba2\u670d\u5728\u8ddf\u626b\u7801\u7684\u8fd9\u4e2a\u7528\u6237\u5bf9\u8bdd\uff0c\u4e0a\u6bb5\u4ee3\u7801\u4e2d\u8c03\u7528\u7684sendMessage()\u662f\u4f7f\u7528\u5ba2\u6237\u8d26\u53f7\u7ed9\u626b\u7801\u7528\u6237\u53d1\u9001\u4e00\u4e2a\u56fe\u6587\u6d88\u606f\uff0c\u56e0\u4e3a\u6211\u5728\u62ffscen_id\u7684\u540c\u65f6\u4e5f\u62ff\u5230\u4e86\u7528\u6237\u7684openid\uff0c\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2a\u7ed9\u7528\u6237\u53d1\u9001\u6d88\u606f\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u4e0b\u9762\u662f&nbsp;<span>sendMessage()<\/span>&nbsp;\u65b9\u6cd5\uff1a<\/span><\/p>\n<pre>\/\/\u7ed9\u7528\u6237\u53d1\u9001\u56fe\u6587\u6d88\u606f\uff0c\u70b9\u51fb\u8df3\u8f6c\u5230\u62a5\u4ef7\u9875\u9762\r\n    public function sendMessage($openid,$orderId){        $url = str_replace('##TOKEN##', getWechatAccessToken(), C('WECHAT_SEND_MESSAGE'));        $redirectUrl = str_replace(\"##ORDERID##\", $orderId, str_replace(\"##OPENID##\", $openid, C('WECHAT_REDIRECT_URL_PRE')));        $orderInfo = M('order')-&gt;where(array('orderid' =&gt; $orderId))-&gt;field(array('totalMoney', 'savedMoney', 'roomarea'))-&gt;find();        $description = str_replace(\"##ROOMAREA##\", intval($orderInfo['roomarea'] * 1.25), C('WECHAT_MESSAGE_BRIEF'));        $description = str_replace(\"##TOTALBUDGET##\", $orderInfo['totalMoney'], $description);        $description = str_replace(\"##MARKETBUDGET##\", $orderInfo['totalMoney']+$orderInfo['savedMoney'], $description);        $description = str_replace(\"##SAVEMONEY##\", $orderInfo['savedMoney'], $description);        $dataStr = '{\"touser\":\"' . $openid . '\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"' . C('WECHAT_MESSAGE_TITLE') .\r\n            '\",\"description\":\"' . $description . '\",\"url\":\"' . $redirectUrl . '\",\"picurl\":\"' . C('WECHAT_MESSAGE_PICURL') . '\"\"}]}}';\r\n        api_notice_increment($url, $dataStr);\r\n    }<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5176\u4e2d&nbsp;<span> C(&#8216;WECHAT_SEND_MESSAGE&#8217;) = &#8216;https:\/\/api.weixin.qq.com\/cgi-bin\/message\/custom\/send?access_token=##TOKEN##&#8217; <\/span>&nbsp;\u81f3\u4e8e\u4e0b\u9762\u7684\u4e00\u5927\u6bb5str_replace\uff0c\u5c31\u662f\u5728\u7ec4\u7ed9\u7528\u6237\u53d1\u9001\u7684\u6587\u5b57\u800c\u5df2\uff0c\u9700\u8981\u6ce8\u610f$dataStr\u7684\u683c\u5f0f\uff0c\u8fd9\u91cc\u9762\u8981\u6c42JSON\u5b57\u7b26\u4e32\u6bd4\u8f83\u4e25\u683c\uff0c\u5fc5\u987b\u6240\u6709\u7684\u5b57\u7b26\u4e32\u90fd\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u3002\u5fae\u4fe1\u63a5\u53e3\u5bf9POST\u53c2\u6570\u7684\u9650\u5236\u771f\u5fc3\u4e25\u683c\u3002<\/span><\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u4e0b\u9762\u662f\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5f00\u53d1\u8005\u6587\u6863\u4e2d\u8981\u6c42\u53d1\u9001\u56fe\u6587\u6d88\u606f\u7684POST data\u683c\u5f0f\uff1a<\/span><\/p>\n<pre>{\r\n    \"touser\":\"OPENID\",\r\n    \"msgtype\":\"news\",\r\n    \"news\":{\r\n        \"articles\": [\r\n         {\r\n             \"title\":\"Happy Day\",\r\n             \"description\":\"Is Really A Happy Day\",\r\n             \"url\":\"URL\",\r\n             \"picurl\":\"PIC_URL\"\r\n         },\r\n         {\r\n             \"title\":\"Happy Day\",\r\n             \"description\":\"Is Really A Happy Day\",\r\n             \"url\":\"URL\",\r\n             \"picurl\":\"PIC_URL\"\r\n         }\r\n         ]\r\n    }\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><span style=\"color: #000000;font-size: 15px\">\u3000\u3000\u5176\u4e2durl\u662f\u7528\u6237\u70b9\u51fb\u8fd9\u4e2a\u6d88\u606f\u4e4b\u540e\u6253\u5f00\u7684\u5730\u5740\uff0c\u8fd9\u4e2a\u65f6\u5019\u6211\u5c31\u7ec4\u4e86\u4e00\u4e2a\u81ea\u5df1\u7f51\u7ad9\u7684\u5730\u5740\uff0c\u662f\u4e00\u4e2aget\u8bf7\u6c42\u5730\u5740\uff0c\u91cc\u9762\u643a\u5e26\u53c2\u6570\u662f\u7528\u6237\u7684openid\u548c\u8ba2\u5355id\uff0c\u8fd9\u6837\u7528\u6237\u70b9\u51fb\u5f00\u56fe\u6587\u6d88\u606f\u5c31\u53ef\u4ee5\u770b\u5230\u81ea\u5df1\u521a\u624d\u4e0b\u5355\u7684\u5185\u5bb9\u4e86\uff0c\u56e0\u4e3a\u9700\u8981\u5728\u7f51\u9875\u4e0a\u5c55\u793a\u7528\u6237\u7684\u5fae\u4fe1\u5934\u50cf\u548c\u6635\u79f0\uff0c\u6240\u4ee5\u6211\u628aopenid\u4e5f\u653e\u5230\u53c2\u6570\u91cc\uff0c\u5728\u9875\u9762\u52a0\u8f7d\u524d\u5148\u62ff\u5230\u7528\u6237\u7684\u4e2a\u4eba\u4fe1\u606f\u548c\u8ba2\u5355\u6570\u636e\uff0c\u518d\u5c55\u793a\u7f51\u9875\u3002\u8fd9\u6837\u6d41\u7a0b\uff1a<strong>\u7528\u6237\u672a\u767b\u5f55\u4e0b\u5355 -&gt; \u751f\u6210\u5fae\u4fe1\u4e8c\u7ef4\u7801 -&gt; \u7528\u6237\u626b\u7801\u5173\u6ce8\u516c\u4f17\u53f7 -&gt; \u67e5\u770b\u8ba2\u5355\u8be6\u7ec6\u4fe1\u606f&nbsp;<\/strong>\u5c31\u5b8c\u6210\u4e86\u3002\u800c\u4e14\u56e0\u4e3a\u8fd9\u4e2a\u56fe\u6587\u6d88\u606f\u6253\u5f00\u540e\u7684\u94fe\u63a5\u643a\u5e26\u7684\u53c2\u6570\u662f\u8fd9\u4e2a\u7528\u6237\u7684\u989dopenid\u548c\u5176\u4e0b\u5355\u7684\u8ba2\u5355ID\uff0c\u4e0d\u7ba1\u5206\u4eab\u5230\u54ea\u513f\uff0c\u7528\u4ec0\u4e48\u6d4f\u89c8\u5668\u6253\u5f00\u90fd\u662f\u53ef\u4ee5\u8bbf\u95ee\u7684\uff0c\u4e14\u5c55\u793a\u7684\u4e5f\u662f\u8fd9\u4e2a\u7528\u6237\u7684\u5934\u50cf\u548c\u6635\u79f0\u4fe1\u606f\uff0c\u8fd9\u4e5f\u662f\u6211\u8981\u5b9e\u73b0\u7684\u4e00\u4e2a\u6548\u679c\u3002<\/span><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5f00\u53d1\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u7684\u5b9e\u4f8b\u8be6\u89e3\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>\u3000\u3000\u6700\u8fd1\u505a\u5fae\u4fe1pc\u7aef\u7f51\u9875\u5fae\u4fe1\u76f8\u5173\u529f\u80fd\u7684\u5f00\u53d1\uff0c\u4ece\u4e00\u4e2a\u65b0\u624b\u7684\u89d2\u5ea6\u6765\u8bf4\uff0c\u5fae\u4fe1\u516c\u4f17\u53f7\u7684\u6587\u6863\u8fd8\u662f\u4e0d\u597d\u7406\u89e3\u7684\uff0c\u7f51\u4e0a\u627e\u7684\u5e16\u5b50\u5927\u90fd\u4e5f\u90fd\u57fa\u672c\u4e0a\u662f\u590d\u5236\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u4e0a\u7ed9\u7684\u6587\u6863\uff0c\u5f00\u53d1\u5fae\u4fe1\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u8fc7\u7a0b\u4e2d\u8fd8\u662f\u9047\u5230\u4e0d\u5c11\u5751\u7684\uff0c\u5728\u6b64\u628a\u6211\u7684\u5f00\u53d1\u8fc7\u7a0b\u6bd4\u8f83\u8be6\u7ec6\u7684\u8bb0\u5f55\u4e0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\u3002 \u3000\u3000\u6211\u672c\u6b21\u5f00\u53d1\u4f7f\u7528\u7684\u662f\u8ba4\u8bc1\u670d\u52a1\u53f7\u3002 1 \u63a5\u5165 \u3000\u3000\u9996\u5148\u8fdb\u5165\u5fae\u4fe1\u516c\u4f17\u53f7 -&gt; \u57fa\u672c\u914d\u7f6e&nbsp; \u3000\u3000\u4e0b\u9762\u662f\u57fa\u672c\u914d\u7f6e\u7684\u9875\u9762\uff0c\u5728URL\u4e2d\u586b\u5199\u670d\u52a1\u5668\u5730\u5740\uff0c\u8fd9\u4e2a\u5730\u5740\u5c31\u662f\u63a5\u53d7\u5fae\u4fe1\u63a8\u9001\u4e8b\u4ef6\u7684\u4e00\u4e2a\u63a5\u53e3\uff0c\u6211\u662f\u4f7f\u7528thinkPHP\u6846\u67b6\u5f00\u53d1\u7684\u7a0b\u5e8f\uff0c\u5728\u5176\u4e2d\u4e00\u4e2aModule\uff08Decoration\uff09\u7684Action\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u7c7b\uff0c\u6bd4\u5982\u53eb\uff1a&nbsp;&nbsp;WechatAction.class.php&nbsp;&nbsp;\uff0c\u5728\u8be5Action\u4e2d\u65b0\u5efa\u4e00\u4e2apublic\u65b9\u6cd5\uff0c\u6bd4\u5982\u53eb\uff1a&nbsp;&nbsp;URLRedirect()&nbsp;&nbsp;\uff0c\u90a3\u4e48\u5728\u8fd9\u4e2aURL\u4e2d\u586b\u5199\u7684\u5c31\u662f&nbsp;&nbsp;http:\/\/[IP]:[port]\/index.php\/Decoration\/Wechat\/UrlRedirect&nbsp;&nbsp;,\u7136\u540e\u586b\u5199Token\uff0cToken\u968f\u610f\u586b\uff0cEncodingAESKey\u8981\u4e0d\u8981\u90fd\u884c\uff0c\u7136\u540e\u70b9\u51fb\u786e\u8ba4\uff0c\u5fae\u4fe1\u4f1a\u5f80\u8fd9\u4e2aURL\u4e0a\u53d1\u9001\u4e00\u4e2aget\u8bf7\u6c42\uff0c\u91cc\u9762\u5305\u542b\u5f88\u591a\u53c2\u6570\uff0c\u5176\u4e2d\u5927\u90e8\u5206\u90fd\u662f\u8ba9\u6211\u4eec\u81ea\u5df1\u6838\u5bf9\u8fd9\u6b21\u8bbf\u95ee\u662f\u4e0d\u662f\u5fae\u4fe1\u670d\u52a1\u5668\u8bf7\u6c42\u7684\uff0c\u6211\u81ea\u5df1\u6ca1\u6709\u9a8c\u8bc1\uff0c\u4ed6\u7684\u8981\u6c42\u662f\u5982\u679c\u6211\u4eec\u6838\u5bf9\u6210\u529f\uff0c\u5373\u539f\u6837\u8fd4\u56deget\u8bf7\u6c42\u4e2d\u7684\u4e00\u4e2a\u53c2\u6570echostr\uff0c\u8fd9\u91cc\u7684\u8fd4\u56de\u4e0d\u662freturn\uff0c\u4e5f\u4e0d\u662fajaxReturn\uff0c\u800c\u4f7f\u7528echo\uff0c\u5982\u679c\u7528thinkPHP\u5f00\u53d1\u7684\u8bdd\uff0c\u76f4\u63a5\u4f7f\u7528&nbsp;&nbsp;echo I(&#8216;echostr&#8217;);&nbsp;&nbsp;\u5373\u53ef\u3002\u7136\u540e\u63a5\u53e3\u5373\u9a8c\u8bc1\u6210\u529f\u4e86\u3002 &nbsp; 2 \u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u7684\u4f5c\u7528 \u3000\u3000\u5fae\u4fe1\u7684\u5e26\u53c2\u6570\u4e8c\u7ef4\u7801\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u4e34\u65f6\u4e8c\u7ef4\u7801\uff0c\u4e00\u79cd\u662f\u6c38\u4e45\u4e8c\u7ef4\u7801\uff0c\u4f46\u662f\u6c38\u4e45\u4e8c\u7ef4\u7801\u7684\u751f\u6210\u662f\u6709\u4e2a\u6570\u9650\u5236\u7684\uff0c\u6211\u8fd9\u6b21\u8981\u5b9e\u73b0\u7684\u529f\u80fd\u662f\u7528\u6237\u672a\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\u5728\u7f51\u7ad9\u4e0a\u4f7f\u7528\u4ea7\u54c1\uff0c\u6bd4\u5982\u83b7\u5f97\u67d0\u5546\u54c1\u7684\u8be6\u7ec6\u62a5\u4ef7\uff0c\u4f46\u662f\u53c8\u4e0d\u60f3\u6ce8\u518c\uff0c\u7136\u800c\u53c8\u60f3\u4fdd\u5b58\u8fd9\u4e2a\u62a5\u4ef7\u5355\uff0c\u8fd9\u4e2a\u65f6\u5019\u7f51\u9875\u53ef\u4ee5\u751f\u6210\u4e00\u5f20\u4e8c\u7ef4\u7801\uff0c\u7528\u6237\u53ea\u8981\u7528\u5fae\u4fe1\u626b\u4e00\u626b\u8fd9\u4e2a\u4e8c\u7ef4\u7801\uff0c\u5b98\u65b9\u516c\u4f17\u53f7\u5c31\u4f1a\u7ed9\u8fd9\u4e2a\u7528\u6237\u53d1\u9001\u4e00\u5929\u56fe\u6587\u6d88\u606f\uff0c\u56fe\u6587\u6d88\u606f\u70b9\u5f00\u540e\u5c31\u662f\u7528\u6237\u521a\u521a\u83b7\u5f97\u7684\u62a5\u4ef7\u5355\uff0c\u800c\u4e14\u53ef\u4ee5\u968f\u65f6\u70b9\u51fb\u67e5\u770b\u5e76\u4e14\u5206\u4eab\u7ed9\u670b\u53cb\u8fdb\u884c\u6bd4\u4ef7\u3002\u6240\u4ee5\u4e34\u65f6\u4e8c\u7ef4\u7801\u5373\u53ef\u6b63\u5e38\u4f7f\u7528\u3002 \u3000\u3000\u4e0a\u9762\u662f\u6211\u662f\u600e\u4e48\u4f7f\u7528\u7684\uff0c\u4e0b\u9762\u4ecb\u7ecd\u4e00\u4e0b\u6574\u4e2a\u4ea4\u4e92\u7684\u6d41\u7a0b\uff1a \u3000\u3000\u5f53\u7528\u6237\u626b\u63cf\u8fd9\u4e2a\u4e8c\u7ef4\u7801\uff0c\u5982\u679c\u7528\u6237\u5173\u6ce8\u4e86\u516c\u4f17\u53f7\uff0c\u7528\u6237\u4f1a\u76f4\u63a5\u8fdb\u5165\u4e0e\u516c\u4f17\u53f7\u7684\u4f1a\u8bdd\u9875\u9762\uff0c\u5fae\u4fe1\u670d\u52a1\u5668\u4f1a\u7ed9\u6211\u4eec\u5728\u4e0a\u4e00\u6b65\u8bbe\u7f6e\u7684\u670d\u52a1\u5668URL\u4e2d\u63a8\u9001\u4e00\u6761\u6d88\u606f\uff0c\u5176\u4e2d\u53ef\u4ee5\u643a\u5e26\u4e00\u4e2a\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u53c2\u6570\u3002\u5982\u679c\u7528\u6237\u672a\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5219\u7528\u6237\u9996\u5148\u4f1a\u8df3\u8f6c\u5230\u516c\u4f17\u53f7\u5173\u6ce8\u9875\u9762\uff0c\u7528\u6237\u70b9\u51fb\u5173\u6ce8\u540e\uff0c\u4f1a\u76f4\u63a5\u8fdb\u5165\u516c\u4f17\u53f7\u7684\u4f1a\u8bdd\u9875\u9762\uff0c\u5fae\u4fe1\u670d\u52a1\u5668\u8fd9\u65f6\u4e5f\u4f1a\u7ed9\u6211\u4eec\u8bbe\u7f6e\u7684URL\u63a8\u9001\u4e00\u4e2a\u4e8b\u4ef6\u6d88\u606f\uff0c\u643a\u5e26\u6211\u4eec\u81ea\u5b9a\u4e49\u53c2\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u53c2\u6570\u548c\u4e8b\u4ef6\u7c7b\u578b\u505a\u63a7\u5236\u4e0b\u4e00\u6b65\u52a8\u4f5c\u3002 &nbsp; 3 \u5177\u4f53\u5f00\u53d1\u8fc7\u7a0b 3.1 \u83b7\u53d6access_token \u3000\u3000\u8fd9\u4e2aaccess_token\u662f\u6211\u4eec\u7a0b\u5e8f\u8c03\u7528\u5fae\u4fe1\u63a5\u53e3\u7684\u51ed\u8bc1\uff0c\u76ee\u524d\u7684\u6709\u6548\u671f\u662f7200\u79d2\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5b9a\u65f6\u66f4\u65b0access_token\u3002 \u3000\u3000\u83b7\u5f97\u65b9\u6cd5\uff1a \u65b9\u6cd5&nbsp;\uff1a&nbsp;GET url&nbsp;\uff1ahttps:\/\/api.weixin.qq.com\/cgi-bin\/token?grant_type=client_credential&amp;amp;appid=APPID&amp;amp;secret=APPSECRET \u767b\u5f55\u540e\u590d\u5236 \u3000\u3000\u5176\u4e2d\u7684\u53c2\u6570APPID\u548cAPPSECRET\u662f\u6211\u4eec\u516c\u4f17\u53f7\u7684APPID\u548cAPPSECRET\uff0c\u5728\u5fae\u4fe1\u516c\u4f17\u53f7 -&gt; \u57fa\u672c\u914d\u7f6e\u4e2d\u53ef\u4ee5\u67e5\u5230\uff0c\u8c03\u7528\u6210\u529f\u4f1a\u8fd4\u56de\u5982\u4e0bJSON\u6570\u636e\uff1a {&#8220;access_token&#8221;:&#8221;ACCESS_TOKEN&#8221;,&#8221;expires_in&#8221;:7200} \u767b\u5f55\u540e\u590d\u5236 \u3000\u3000\u5176\u4e2daccess_token\u5c31\u662f\u8c03\u7528\u63a5\u53e3\u51ed\u8bc1\uff0cexpire_in\u662ftoken\u6709\u6548\u65f6\u95f4\u3002 \u3000\u3000\u6211\u672c\u4eba\u662f\u628aaccess_token\u5b58\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u540c\u65f6\u4fdd\u5b58\u8fc7\u671f\u65f6\u95f4\uff0c\u7136\u540e\u5c01\u88c5\u516c\u7528\u51fd\u6570&nbsp;&nbsp;getWechatAccessToken()&nbsp;&nbsp;\uff0c\u6bcf\u6b21\u5148\u68c0\u67e5access_token\u662f\u5426\u8fc7\u671f\uff0c\u5982\u679c\u8fc7\u671f\u5219\u91cd\u65b0\u83b7\u53d6\uff0c\u5426\u5219\u76f4\u63a5\u4f7f\u7528\u6570\u636e\u5e93\u4fdd\u5b58\u7684access_token\u5373\u53ef\uff0c\u6211\u5fd8\u4e86\u5728\u54ea\u513f\u770b\u52a0\u8fc7\uff0c\u8fd9\u4e2aaccess_token\u6bcf\u5929\u7684\u83b7\u53d6\u6b21\u6570\u5e94\u8be5\u662f\u6709\u9650\u5236\u7684\u3002\u4e0b\u9762\u662f&nbsp;&nbsp;getWechatAccessToken()&nbsp;&nbsp; \u7684\u5177\u4f53\u5b9e\u73b0\uff1a &nbsp;1&nbsp;\/\/\u83b7\u53d6access_token &nbsp;2&nbsp;function&nbsp;getWechatAccessToken(){&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wechatInfo&nbsp;=&nbsp;M(&#8216;wechat_info&#8217;)-&amp;gt;select();&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wechatInfo&nbsp;=&nbsp;array_reduce($wechatInfo,&nbsp;create_function(&#8216;$result,&nbsp;$v&#8217;,&nbsp;&#8216;$result[$v[&#8220;conf_name&#8221;]]&nbsp;=&nbsp;$v;return&nbsp;$result;&#8217;));&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$expireTime&nbsp;=&nbsp;$wechatInfo[&#8216;PUBLIC_WECHAT_ACCESSTOKEN_EXPIRES&#8217;][&#8216;conf_value&#8217;];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u524d\u9762\u4e0d\u7528\u7ba1\uff0c\u662f\u6211\u6570\u636e\u5e93\u76f8\u5e94\u8bbe\u7f6e &nbsp;6&nbsp; &nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(time()&nbsp;where(array(&#8216;conf_name&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;PUBLIC_WECHAT_ACCESSTOKEN&#8217;))-&amp;gt;save(array(&#8216;conf_value&#8217;&nbsp;=&amp;gt;&nbsp;$result[&#8216;access_token&#8217;]));19&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;M(&#8216;wechat_info&#8217;)-&amp;gt;where(array(&#8216;conf_name&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;PUBLIC_WECHAT_ACCESSTOKEN_EXPIRES&#8217;))-&amp;gt;save(array(&#8216;conf_value&#8217;&nbsp;=&amp;gt;&nbsp;time()+$result[&#8216;expires_in&#8217;]-200));20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$result[&#8216;access_token&#8217;];21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}23&nbsp;} \u767b\u5f55\u540e\u590d\u5236 C(&#8216;WECHAT_PUBLIC_GET_ACCESS_TOKEN&#8217;)&nbsp;=&nbsp;https:\/\/api.weixin.qq.com\/cgi-bin\/token?grant_type=client_credential&amp;amp;appid=APPID&amp;amp;secret=APPSECRET \u767b\u5f55\u540e\u590d\u5236 \u3000\u3000\u5c01\u88c5\u597d\u8fd9\u4e2a\u4e4b\u540e\uff0c\u6211\u4eec\u6bcf\u6b21\u5c31\u53ef\u4ee5\u5b89\u5fc3\u7684\u4f7f\u7528\u4e86\u3002 3.2 \u521b\u5efa\u4e34\u65f6\u4e8c\u7ef4\u7801 3.2.1 \u83b7\u53d6ticket \u3000\u3000\u3000\u3000&nbsp;&nbsp;\u8bf7\u6c42\u65b9\u5f0f\uff1a&nbsp;POST \u3000\u3000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u63a5\u53e3\uff1ahttps:\/\/api.weixin.qq.com\/cgi-bin\/qrcode\/create?access_token=TOKEN &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;POST\u6570\u636e\uff1a&nbsp;{&#8220;expire_seconds&#8221;:&nbsp;604800,&nbsp;&#8220;action_name&#8221;:&nbsp;&#8220;QR_SCENE&#8221;,&nbsp;&#8220;action_info&#8221;:&nbsp;{&#8220;scene&#8221;:&nbsp;{&#8220;scene_id&#8221;:&nbsp;123}}} \u767b\u5f55\u540e\u590d\u5236 \u3000\u3000\u63a5\u53e3URL\u4e2d\u7684TOKEN\u5373\u6211\u4eec\u57283.1\u4e2d\u83b7\u53d6\u7684access_token\uff0cpost\u6570\u636e\u4e2dexpire_seconds\u662f\u4e8c\u7ef4\u7801\u7684\u6709\u6548\u65f6\u95f4\uff0c\u6700\u591a\u4e3a30\u5929\uff0caction_name\u4e34\u65f6\u4e8c\u7ef4\u7801\u7684\u8bdd\u56fa\u5b9a\u5c31\u662fQR_SCENE\uff0cscene_id\u5373\u6211\u4eec\u81ea\u5b9a\u4e49\u53c2\u6570\uff0c\u662f\u4e2a32\u4f4d\u975e0\u6574\u6570\uff0c\u6211\u5728\u5e94\u7528\u4e2d\u628a\u5b83\u8bbe\u4e3a\u8ba2\u5355\u7684ID\uff0c\u5fae\u4fe1\u670d\u52a1\u5668\u63a8\u9001\u4e8b\u4ef6\u7684\u65f6\u5019\u4f1a\u628a\u8fd9\u4e2a\u503c\u8fd4\u56de\u7ed9\u6211\u4eec\u8bbe\u7f6e\u7684\u63a5\u53e3\u4e2d\uff0c\u7136\u540e\u6211\u4f1a\u6839\u636e\u8fd9\u4e2a\u503c\u53bb\u62ff\u76f8\u5e94\u7684\u8ba2\u5355\u6570\u636e\u5c55\u793a\u5728\u7f51\u9875\u4e0a\uff0c\u8fd9\u662f\u540e\u8bdd\u3002 \u3000\u3000\u4e0b\u9762\u662f\u5c01\u88c5\u7684\u751f\u6210\u4e34\u65f6\u4e8c\u7ef4\u7801\u7684\u65b9\u6cd5\uff1a \/\/\u521b\u5efa\u4e34\u65f6\u4e8c\u7ef4\u7801function&nbsp;getTemporaryQrcode($orderId){&nbsp;&nbsp;&nbsp;&nbsp;$accessToken&nbsp;=&nbsp;getWechatAccessToken();&nbsp;&nbsp;&nbsp;&nbsp;$url&nbsp;=&nbsp;str_replace(&#8220;##TOKEN##&#8221;,&nbsp;$accessToken,&nbsp;C(&#8216;WECHAT_PUBLIC_GET_TEMPORARY_TICKET&#8217;));&nbsp;&nbsp;&nbsp;&nbsp;$qrcode&nbsp;=&nbsp;&#8216;{&#8220;expire_seconds&#8221;:&nbsp;1800,&nbsp;&#8220;action_name&#8221;:&nbsp;&#8220;QR_SCENE&#8221;,&nbsp;&#8220;action_info&#8221;:&nbsp;{&#8220;scene&#8221;:&nbsp;{&#8220;scene_id&#8221;:&nbsp;&#8216;.$orderId.&#8217;}}}&#8217;;&nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;api_notice_increment($url,&nbsp;$qrcode);&nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;json_decode($result,&nbsp;true);&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;urldecode($result[&#8216;url&#8217;]); } \u767b\u5f55\u540e\u590d\u5236 \u3000\u3000\u5176\u4e2d\u7684\u65b9\u6cd5 [&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-29942","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29942","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=29942"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29942\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}