PHP development WeChat Public number, your server does not respond correctly token authentication, please read the Message Interface Usage Guide

Source: Internet
Author: User
When using the URL and token to enable the public Platform Development Mode message interface, the display] "Your server does not respond correctly to token authentication, please read the Message Interface Usage Guide", do not know what is the case, my token verification code with the development documentation in the sample code, is the server in the SAE application. The code is as follows (I see the solution on the Internet, say write Tracehttp () This method to see Log.html file, but i in the server code directory inside and did not find log.html file), seek the guidance of the Great God

Define ("TOKEN", "Weixin");
Tracehttp ();
$WECHATOBJ = new WeChat ();
$WECHATOBJ->valid ();

Class WeChat {

Public Function valid () {

$ECHOSTR = $_get ["Echostr"];

if ($this->checksignature ()) {
Echo $echoStr;
Exit ();
}
}
Private Function Checksignature () {
$signature = $_get ["signature"];
$timestamp = $_get ["timestamp"];
$nonce = $_get ["nonce"];

$token = token;
$TMPARR = Array ($token, $timestamp, $nonce);
Sort ($TMPARR, sort_string);
$TMPSTR = implode ($TMPARR);
$TMPSTR = SHA1 ($TMPSTR);

if ($tmpStr = = $signature) {
return true;
} else {
return false;
}
}
}
function Tracehttp () {
Logger ("REMOTE_ADDR:". $_server [' REMOTE_ADDR '].
((Strpos ($_server [' REMOTE_ADDR '], "101.226"))? " From Weixin ":" Unknown IP "));

Logger ("query_string:". $_server["Query_string"]);

}
function Logger ($content)
{
File_put_contents ("\log.html", Date (' y-m-d h:i:s '). $content. "
", file_append);
}

?>


Reply to discussion (solution)

Is the URL you visited error?

Yes, I downloaded a code package on the Internet again, but it was the same as before. I uploaded it again, and then I was able to access it, not knowing what was going on.

  • 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.