[WeChat Development] WeChat public platform access and binding prompt "request URL timeout" solution, public url

Source: Internet
Author: User

[Development] public platform access and binding prompt "request URL timeout" solution, public url
Become a developer's first step-public platform accessStep 1: Fill in the server configuration

Enable server configuration in development> basic configuration. Modify configurations

The URL is the interface URL used by the developer to receive messages and events.

The Token can be entered by the developer as needed to generate a signature (the Token will be compared with the Token contained in the interface URL to verify security ).

The EncodingAESKey is manually entered or randomly generated by the developer and will be used as the accesskey for message body encryption and decryption.

Click to submit

Step 2: verify the validity of the server address

After the developer submits the information, the server sends a GET request to the server Address URL filled in. The GET request carries four parameters:

Signature ------ encrypted signature. signature combines the token parameter entered by the developer with the timestamp and nonce parameters in the request.

Timestamp ------ timestamp

Nonce ------ Random Number

Echostr ------ random string

The developer verifies the request by verifying signature (The following is a verification method ). If you confirm that the GET request is from the server, return the content of the echostr parameter as it is, the access takes effect and becomes a developer. Otherwise, the access fails.

// Obtain the Token value and UID $ memberModel = D ('member'); $ userinfo = $ memberModel-> getWechatInfo (WID ); // obtain the user's account information $ weixinLogic = D ('weixin', 'lock'); $ Weixin = $ weixinLogic-> detail (WID ); $ weixin = new ThinkWechat ($ userinfo ['Token']);

In the public functions, verify signature:

If (IS_GET) {$ this-> auth ($ token) | die ('token information error'); exit ($ _ GET ['echostr']);} /*** perform signature authentication on the data to ensure that the data is sent * @ param string $ token the TOKEN set on the token Open Platform * @ return boolean true-the signature is correct, false-signature Error */private function auth ($ token) {/* GET data */$ data = array ($ _ GET ['timestamp'], $ _ GET ['nonce '], $ token); $ sign = $ _ GET ['signature'];/* sort data alphabetically */sort ($ data, SORT_STRING);/* generate a signature */$ signature = sha1 (implode ($ data); return $ signature ===$ sign ;}

Note:After that, each time a user sends a message to the public account or generates a custom menu Click Event, the server configuration URL entered by the developer will receive messages and events pushed by the server, then, developers can respond to messages based on their own business logic, such as replying to messages.

 

 

When the public platform is bound, the system prompts "request URL timeout". solution:

Generally, this problem occurs only on windows servers, but not on Linux servers. The specific cause is that the database information of mysql is configured as localhost and an error occurs, change the 'db _ HOST address to 127.0.0.1 in the database configuration file.

Note:It is best to use notepad instead of notepad to open the database link file.

Copyright owned by the author

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.