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

学习php微信开发应用接入API接口笔记

2016-11-23 19:36 841 查看
课程地址:http://www.imooc.com/learn/483

1、打开自已的微信公众平台·:https://mp.weixin.qq.com

2、点击左边底部的基本配置:



3、修改配置



4、填写基本配置

URL:我们可以访问的公共地址

token:我们可以任意写(token是什么,在这里就不唠叨了)

EncodingAESKey:点击随机生成

最后点击提交(这时我们提交会失败)why?

我们要配置weixin.php

配置代码:

<?php

//获得参数 signature nonce token timestamp echostr
$nonce = $_GET['nonce'];
$token = 'weixin';
$timestamp = $_GET['timestamp'];
$echostr = $_GET['echostr'];
$signature = $_GET['signature'];
//形成数组,然后按字典序排序
$array = array();
$array = array($nonce, $timestamp, $token);
sort($array);
//拼接成字符串,sha1加密 ,然后与signature进行校验
$str = sha1( implode( $array ) );
if( $str == $signature && $echostr ){
//第一次接入weixin api接口的时候
echo $echostr;
exit;
}

记得把写好的weixin.php文件上传到服务器喔~

5.最后在基本配置页面的服务器配置要启动

这时返回步骤四,重新提交,这时就会token验证成功

返回到基本配置页面时出现:

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