您的位置:首页 > 移动开发 > 微信开发

微信token验证代码

2015-11-14 10:36 513 查看
<?php
/**
* wechat php test
*/

//define your token
define("TOKEN", "weixin");

$signature = $_GET['signature'];
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$echostr = $_GET['echostr'];

$token = TOKEN;
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );

if( $tmpStr == $signature ){
//没加这一句一直token验证失败
header('content-type:text');
echo $echostr;
}

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: