<?php
/**
* Created by PhpStorm.
* User: 兔儿神
* Date: 2017/9/11
* Time: 8:55
*/
namespace app\modules\wechat\controllers;
use yii\web\Controller;
class ExamController extends Controller
{
public function actionIndex()
{
if($this->checkMsg()) {
echo $_GET['echostr'];
}
}
private function checkMsg()
{
$token = 'tuershen';//自定义
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$signature = $_GET['signature'];
$tmp = [$token, $timestamp, $nonce];//$token、$timestamp、$nonce放在一个数组中
sort($tmp, SORT_STRING);//将token、timestamp、nonce三个参数进行字典序排序
$tmp_sha1 = sha1(implode('',$tmp));//将三个参数字符串拼接成一个字符串进行sha1加密
//开发者获得加密后的字符串可与signature对比
if ($tmp_sha1 == $signature) {
return true;
} else {
return false;
}
}
}
https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
打开连接,修改配置
URL 一定要写正确,token是你自定义好的
$token = 'tuershen';//自定义
这样修改配置就成功了
微信 接口配置信息修改
最新推荐文章于 2023-08-16 15:59:53 发布