1.url就是正常能请求到的地址就行
2.把我卡了一天的地方,就是给微信服务器返回’echostr’
主要函数ob_clean();
不知道你们会遇到什么样的问题,我是主要这个函数解决的,清空缓存区的内容
public function notify()
{
$signature = $_GET['signature'];
$timestamp = $_GET['timestamp'];
$echostr = $_GET['echostr']; //接收传递字符串
$nonce = $_GET['nonce'];
$token = TOKEN; //和设置的Token一致
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
//前面的全不用动,主要是给服务器返回的部分,我网上搜的又是转字符串,又是干啥的,很多都没用
if ($tmpStr == $signature) {
ob_clean(); //这个位置
echo $echostr;
exit;
} else {
echo '返回失败';
exit;
}
}