1.开发者ID,秘钥:(重要,遗失后如果重置会丢失信息)
ID: w***************b2bcd ;
秘钥:fc0************4f3b;
2.编辑器设置:
1.新建文件夹,在phpstorm中单一打开这个文件,
2.打开右侧工作器,和设置代码自动实时同步
然后测试一下,成功后保存就好
3.服务器配置:
1. 启用前先修改配置
2. URL:需配置线上服务器,配置二级域名就好 wechat.mumeng.xyz
3. IP白名单:将主机ip加入
4.
5. 在phpstorm中新建index.php文件,输入一下内容:
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = 'mengju';
$tmpArr = array($token,$timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
//测试
//file_put_contents ('./a.php',$tmpStr);
//file_put_contents ('./b.php',$signature);
if( $tmpStr == $signature ){
echo $_GET['echostr'];exit;
}else{
return false;
}
6.点击启用配置结束。
三 回复多图文
public function responseFull($content){
$message = $this->getMassage();
$time = time();
$str2 = '';
$str = <<<str
<xml>
<ToUserName><![CDATA[{$message->FromUserName}]]></ToUserName>
<FromUserName><![CDATA[{$message->ToUserName}]]></FromUserName>
<CreateTime>{$time}</CreateTime>
<MsgType><![CDATA[news]]></MsgType>
<ArticleCount>2</ArticleCount>
<Articles>
str;
foreach($content as $v){
$str2 .=<<<str
<item>
<Title><![CDATA[{$v['title']}]]></Title>
<Description><![CDATA[{$v['description']}]]></Description>
<PicUrl><![CDATA[{$v['picUrl']}]]></PicUrl>
<Url><![CDATA[{$v['url']}]]></Url>
</item>
str;
}
$str3= <<<str
</Articles>
</xml>
str;
echo $str.$str2.$str3;
}