消息推送配置url(服务器地址),消息推送url配置问题-请求超时,请检查信息是否填写正确?...
可以正常访问
PHP代码如下:
/**
* wechat php test
*/
//define your token
define("TOKEN", "*******");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
class wechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET['echostr'];
//valid signature , option
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
private function checkSignature()
{
// you must define TOKEN by yourself
if (!defined($_GET['echostr'])) {
echo "TOKEN is not defined!";
}
$signature = $_GET['signature'];
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$token = TOKEN;
$tmpArr = array($token, $timestamp, $nonce);
// use SORT_STRING rule
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
echo $_GET['echostr'];
}else{
echo false;
}
}
}
?>