This system tutorial illustrates the interface development process by using the weather god (WeatherGod account, which supports weather query of nearly 2500 counties and cities in China) on the public platform. You are welcome to pay attention to this account. the QR code is shown in the bottom figure.
This system tutorial is applied on the public platformWeather God(Account WeatherGod, supports near Domestic2500County and City weather query) as an example to explain the interface development process. You are welcome to pay attention to this account. the QR code is shown in the bottom figure.
Prerequisites: you have an HTTP server host space on the Internet and the permission to create directories and upload files. Yes for free, but a second-level domain name is required. If you want to quickly apply for a free stable and easy to use service, you can use Sina's SAE first. However, the free time is subject to restrictions.
I. Register a fair platform account
Address: http://mp.weixin.qq.com/
For more information about registration, see:
- Graphic tutorials on public platform registration and certification
- Public Platform message management and group text tutorials
- Document editing and automatic reply tutorials on the public platform
- Graphic tutorial on public platform development mode
- Public platform public meeting account usage details
II. Upload code
The following code is the message interface authentication code. Save the following PHP code as index. php (MytokenAnd upload it to the directory specified by the HTTP server,
Valid (); class wechatCallbackapiTest {public function valid () {$ echoStr = $ _ GET ["echostr"]; // random string if ($ this-> checkSignature ()) {echo $ echoStr; exit ;}} private function checkSignature () {$ signature =$ _ GET ["signature"]; // encrypted signature $ timestamp = $ _ GET ["timestamp"]; // timestamp $ nonce = $ _ GET ["nonce"]; // random number $ token = TOKEN; $ tmpArr = array ($ token, $ timestamp, $ nonce); sort ($ tmpArr); // performs lexicographically ordered sorting // after sha1 encryption and signature pair Than if (sha1 (implode ($ tmpArr) ==$ signature) {return true;} else {return false ;}}?>
Or download the sample code directly. Address http://mp.weixin.qq.com/mpres/htmledition/res/wx_sample.zip
II. enable the Message Interface
Go to the public platform and selectSet-Keyword automatic reply, SelectEnable, Click next to the message interface of the public platformEditTo go to the interface configuration page:
Enter the following options as required. Note that the URL is the path where you Upload index. php. it must start with http: // and port 80.
After filling in the information, click Submit. the following results will be displayed:
1.Your server does not correctly respond to Token verification. please read the message interface user guide.
Check whether the configuration is correct. If you are sure that the configuration is correct, follow these steps to check
2. Request URL timeout
Your server is abroad, or the server's network speed is not powerful. you can try it several times. If this happens frequently, consider changing the server.
3. submission successful
Congratulations, the configuration is successful.