其他分享
首页 > 其他分享> > 微信接口信息配置

微信接口信息配置

作者:互联网

核心代码

class Wechat
{
public function __construct()
{
     //构造函数直接调用微信官方给的私有方法
$this->checkSignature();
}
    //微信官方给的核心代码
private function checkSignature()
{
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
      
$echostr = $_GET["echostr"];
    //与上图的Token保持一致
$token = 'php';
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );

if( $tmpStr == $signature ){
echo $echostr;
}else{
return false;
}
}
      //调用共有方法
public function index()
{

}

}
官方文档
https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html

标签:nonce,function,GET,微信,tmpArr,配置,接口,echostr,tmpStr
来源: https://www.cnblogs.com/jxlong/p/15780559.html