微信开发token验证失败的解决办法
第一天做微信开发,需要验证token。
1、在公众号里设置好了相关信息。
2、在服务器对应的url下放网页。
<?php
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$token = "你的token";
$signature = $_GET['signature'];
$array = array($timestamp,$nonce,$token);
sort($array);
$tmpstr = implode('',$array);
$tmpstr = sha1($tmpstr);
if($tmpstr == $signature)
{
ob_clean();
header('content-type:text');
echo $_GET['echostr'];
exit;
}
结果,一直显示token验证失败,nnd。
3、把token改成 caonima,还是token验证失败。
4、把php文件格式改成utf-8 ascii,成功了! 腾讯真弱智。