Your server does not correctly respond to Token verification. please refer to the message interface user guide when using URL and Token to enable the public platform development mode message interface, "Your server does not correctly respond to Token verification. please read the message interface user guide, my token verification code uses the sample code in the development documentation, which is the server applied for at SAE. Hosts file ).
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 accessed reported an error?
I downloaded a code package online, but it is the same as before. I uploaded it again, and then I can access it. I don't know what's going on.