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

微信 接口配置信息修改

2017-09-12 08:51 267 查看
<?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';//自定义
这样修改配置就成功了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐