Home > php教程 > php手册 > 微信公共号的PHP开发(基础篇)——玩一下 - 韧还

微信公共号的PHP开发(基础篇)——玩一下 - 韧还

WBOY
Release: 2016-05-20 09:33:49
Original
1379 people have browsed it

  最近没事儿开了个微信号,写点东西给家人啊什么的看,你们想看的话就这个嘛:

然后就意外的看到imooc上的微信公众号开发相关了。每天科研的累累的,做点这个不是很累的东西吧。

 

微信公共号开发

一、基础

1.1 数据交互流程

用户《————》微信服务器《————》第三方服务器;

且,由左向右都是request,由右向左都是response;

1.2 API

--配置

接入API

 输入这两个——所以,要事先准备好服务器,我用的是腾讯的,反正都是一家的,更方便一点吧。

<span style="color: #800080;">$timestamp</span>=<span style="color: #800080;">$_GET</span>['timestamp'<span style="color: #000000;">];
</span><span style="color: #800080;">$nonce</span>=<span style="color: #800080;">$_GET</span>['nonce'<span style="color: #000000;">];
</span><span style="color: #800080;">$token</span>='weixin'<span style="color: #000000;">;
</span><span style="color: #800080;">$signature</span>=<span style="color: #800080;">$_GET</span>['signature'<span style="color: #000000;">];
</span><span style="color: #800080;">$array</span>=<span style="color: #0000ff;">array</span>(<span style="color: #800080;">$timestamp</span>,<span style="color: #800080;">$nonce</span>,<span style="color: #800080;">$token</span><span style="color: #000000;">);
</span><span style="color: #008080;">sort</span>(<span style="color: #800080;">$array</span><span style="color: #000000;">);
</span><span style="color: #800080;">$tmpstr</span>=<span style="color: #008080;">implode</span>('',<span style="color: #800080;">$array</span><span style="color: #000000;">);
</span><span style="color: #800080;">$tmpstr</span>=<span style="color: #008080;">sha1</span>(<span style="color: #800080;">$tmpstr</span><span style="color: #000000;">);
</span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$tmpstr</span>==<span style="color: #800080;">$signature</span><span style="color: #000000;">){
  </span><span style="color: #0000ff;">echo</span> <span style="color: #800080;">$_GET</span>['echostr'<span style="color: #000000;">];
  </span><span style="color: #0000ff;">exit</span><span style="color: #000000;">;
}</span>
Copy after login

主要就这么一段代码,放在你要链接到的url即可。

具体为什么,是根据weixin规定的来的吧,我也不是很懂,要去查一下。

 

明天开发点东西玩下

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template