[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