进入高级功能-开发模式,下面会有成为开发者按钮,点击该按钮,如果你之前已经设置好头像什么的,就进入下面的页面:
这里token可以随意定义,url输入的不行就通过不了,会提示url超时,或者你的服务器没有正确响应Token验证,请阅读消息接口使用指南,下面你要有你的主机,写一个php文件,内容如下,将此php文件的url地址写上就ok了:
- <?php
- define ( "TOKEN", "dismath" );
- $wechatObj = new wechatCallbackapiTest();
- $wechatObj->valid();
- class wechatCallbackapiTest
- {
- public function valid()
- {
- $echoStr = $_GET["echostr"]; //随机字符串
- if($this->checkSignature()){
- echo $echoStr;
- exit;
- }
- }
- private function checkSignature() {
- $signature = $_GET ["signature"];
- $timestamp = $_GET ["timestamp"];
- $nonce = $_GET ["nonce"];
- $token = TOKEN;
- $tmpArr = array (
- $token,
- $timestamp,
- $nonce
- );
- sort ( $tmpArr );
- $tmpStr = implode ( $tmpArr );
- $tmpStr = sha1 ( $tmpStr );
- if ($tmpStr == $signature) {
- return true;
- } else {
- return false;
- }
- }
- }