Public Platform developer Public Platform Developer Public Platform Development mode signature Check message response
Author: Fang Times studio
Original: http://www.cnblogs.com/txw1958/archive/2013/05/08/weixin-if29-valid-responseMsg.html
I. Source of the problem
The public platform uses the valid function to verify when the interface is enabled,
< span="">("TOKEN", "Square double studio" < span=""> < span=""> < span=""> < span=""> < span=""> ->valid ();
But after the validation is complete, the response to the message is started, the valid function is no longer used, it needs to be commented out, and set to Responsemsg ()
As follows
< span="">("TOKEN", "Square double studio" < span=""> < span=""> < span=""> < span=""> ->responsemsg (); < span="">
This operation, in fact, is more troublesome, because to go back to change the function.
Second, the problem analysis
Why use two different functions to deal with it? This is because two different functions perform different functions,
When executing the valid function, a validation string is submitted to ensure that the URL and token fill-in is submitted correctly, and that the server submits a request to the URL
< span="">=eded789463180edf6c13691398d0cb4c85fb0e23< span="">=5838479218127813673< span="">=1359100969 < span=""> =1359376876
When the response to the message, it can be determined that the URL address is correct, this time is mainly to obtain the response of the XML, when the request submitted similar to the following:
< span="">=ba7f5cf8aee512037e5a669596f6f64a8e763d7c< span="">=1368016183< span="">=1368211921
Second, the solution
Let's look back at the valid function
< span="">< span="">< span="">< span="">< span="">["Echostr"< span="">(< span="">< span="">< span=""> < span=""> -< span="">< span="">< span="">< span="">< span="">< span="">
There is a _get variable, then what is the _get variable, the following is from http://www.w3school.com.cn/php/php_get.asp
$_get variable
The $_get variable is an array of variable names and values that are sent by the HTTP GET method.
The $_get variable is used to collect values from the form method= "GET". Information sent from a form with a GET method is visible to anyone (displayed in the browser's address bar) and has a limit (up to 100 characters) to the amount of messages sent.
Why use $_get?
Note: When using the $_get variable, all variable names and values are displayed in the URL. Therefore, this method should not be used when sending passwords or other sensitive information. However, because the variable is displayed in the URL, you can bookmark the page in the Favorites folder. In some cases, this is useful.
We note that two different requests, described in two, have a echostr variable in the URL in the signature verification request, and no in the response message.
< span="">=eded789463180edf6c13691398d0cb4c85fb0e23=5838479218127813673< span=""> < span=""> =1359100969< span="">=1359376876
Then we use the same idea, to determine whether the _get variable has this echostr variable, to achieve the distinction between two different requests:
The final code looks like this:
< span="">< span="">< span="">("TOKEN", "Square double studio" < span=""> < span=""> < span=""> < span=""> < span=""> ([' Echostr ' < span=""> < span="">< span=""> < span=""> < span="">,< span="">< span="">< span="">< span="">
At this point, we don't have to comment again. One enables another, reducing the hassle.
http://www.bkjia.com/PHPjc/440276.html www.bkjia.com true http://www.bkjia.com/PHPjc/440276.html techarticle Public Platform developer public Platform developer Public Platform development Mode signature Checksum message response Author: Fang Times Studio Original: Http://www.cnblogs.com/txw1958/archi ...