As a WeChat developer using code or to implement functions such as event response, the basic configuration of WeChat development is an indispensable link. This article roughly outlines the development configuration process.
1. Log in to the WeChat public platform: Development ---> Basic configuration
2. There is "Server Configuration" on the basic configuration page. It is not enabled by default. We need to click "Modify Configuration" first to fill in the relevant items
3. Fill in the following items
<span> 1</span> <?<span>php </span><span> 2</span> <span>define</span>("TOKEN", "此处填写你设置的token值"<span>); </span><span> 3</span> <span> 4</span> <span>$wechatObj</span> = <span>new</span><span> CallbackAPI; </span><span> 5</span> <span>$wechatObj</span>-><span>valid(); </span><span> 6</span> <span> 7</span> <span>class</span><span> CallbackAPI { </span><span> 8</span> <span> 9</span> <span>/*</span><span>* </span><span>10</span> <span> * 签名验证 </span><span>11</span> <span> * @return [type] [description] </span><span>12</span> <span>*/</span> <span>13</span> <span>public</span> <span>function</span><span> valid() { </span><span>14</span> <span>$echoStr</span> = <span>$_GET</span>["echostr"<span>]; </span><span>15</span> <span>$signature</span> = <span>$_GET</span>["signature"<span>]; </span><span>16</span> <span>$timestamp</span> = <span>$_GET</span>["timestamp"<span>]; </span><span>17</span> <span>$nonce</span> = <span>$_GET</span>["nonce"<span>]; </span><span>18</span> <span>$token</span> =<span> TOKEN; </span><span>19</span> <span>//</span><span>将token、timestamp、nonce按字典序排序</span> <span>20</span> <span>$tmpArr</span> = <span>array</span>(<span>$token</span>, <span>$timestamp</span>, <span>$nonce</span><span>); </span><span>21</span> <span>sort</span>(<span>$tmpArr</span><span>); </span><span>22</span> <span>$tmpStr</span> = <span>implode</span>(<span>$tmpArr</span><span>); </span><span>23</span> <span>//</span><span>对tmpStr进行sha1加密</span> <span>24</span> <span>$tmpStr</span> = <span>sha1</span>(<span>$tmpStr</span><span>); </span><span>25</span> <span>if</span>(<span>$tmpStr</span> == <span>$signature</span><span>){ </span><span>26</span> <span>header</span>('content-type:text'<span>); </span><span>27</span> <span>echo</span> <span>$echoStr</span><span>; </span><span>28</span> <span>exit</span><span>; </span><span>29</span> <span> } </span><span>30</span> <span> } </span><span>31</span> }
Run index.php in the browser. If the program is correct, you can see the returned string, and the verification is completed at this time. Fill in the token in the code into the corresponding position in the basic configuration, and click Submit. (Note: After submission, a "token verification failed" prompt may appear. If the code and parameters are correct, you need to click a few more times to submit successfully )
4. After the submission is successful, click the "Enable" button to enter the developer mode. After this mode is enabled, some functions ---> Custom menu and other functions will be unavailable. If you want to use it, click "Stop" Just use "
Hereby declare: The relevant articles are all compiled from the problems encountered in the actual development situation after consulting the information and reading the blog posts of great experts. If you can find the original blog, you will definitely sign it. If you can't find the original blog, you will be signed. The quoted content also goes to the original blogger Haihan