(1) Basic configuration for WeChat public account development, basic configuration for Xin public account development_PHP tutorial

WBOY
Release: 2016-07-12 09:01:47
Original
1192 people have browsed it

(1) Basic configuration for the development of WeChat public accounts, basic configuration for the development of public accounts

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

  • URL: must start with http://, currently only supports port 80, the server address must be an accessible and valid address (Note: Using the URL in this article as an example, I once saw a blog post that The URL address is filled in as http://tx.heivr.com/token, but in actual development, the event cannot be responded to. Modifying the URL to a specific file will succeed );
  • EncodingAESKey can be randomly generated;
  • token: WeChat particularly emphasizes that the filled in URL needs to respond to the token, so it needs to be verified in index.php, the code is as follows:
    <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> }
    Copy after login

    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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1087776.htmlTechArticle (1) Basic configuration for WeChat public account development. Basic configuration for WeChat public account development is for WeChat developers who use code or want to To realize functions such as event response, basic configuration of WeChat development is essential...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!