<?php
/*
doufudiy www.dftealife support
CopyRight 2014 All Rights Reserved
*/
define("TOKEN", "doufudiy");
define("AppID", "wx9b24c99e83238b21");
define("EncodingAESKey", "ww1bzDRcAy84UOGNaxL230A9tdBBOWgKQkYviIc6CFc");
define("APP_SECRET", "267980781c9addd54fcf811ea7acb59d");//改成自己的APPSECRET
$wechatObj = new wechatCallbackapiTest();
$wechatObj->responseMsg();
class wechatCallbackapiTest
{
private $app_id;
private $app_secret;
public function valid()
{
$echoStr = $_GET["echostr"];
//valid signature , option
if($this->checkSignature()){
ob_clean();
echo $echoStr;
exit;
}
}
function txt($fu,$tu,$content,$flag = 0){
$tpl = "<xml>
<ToUserName><![CDATA[".$fu."]]></ToUserName>
<FromUserName><![CDATA[".$tu."]]></FromUserName>
<CreateTime>".$_SERVER['REQUEST_TIME']."</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[".$content."]]></Content>
php好看主页源码 <FuncFlag>".$flag."</FuncFlag>
</xml>";
echo $tpl;
}
function news($fu,$tu,$data,$flag = 0){
$num = count($data);
if($num > 1){
$add = $this->news_add($data);
$tpl = " <xml>
<ToUserName><![CDATA[".$fu."]]></ToUserName>
<FromUserName><![CDATA[".$tu."]]></FromUserName>
<CreateTime>".$_SERVER['REQUEST_TIME']."</CreateTime>
<MsgType><![CDATA[news]]></MsgType>
<Content><![CDATA[%s]]></Content>
<ArticleCount>".$num."</ArticleCount>
<Articles>
".$add."
</Articles>
<FuncFlag>".$flag."</FuncFlag>
</xml> ";
echo $tpl;
}else{
$tpl = " <xml>
<ToUserName><![CDATA[".$fu."]]></ToUserName>
<FromUserName><![CDATA[".$tu."]]></FromUserName>
<CreateTime>".$_SERVER['REQUEST_TIME']."</CreateTime>
<MsgType><![CDATA[news]]></MsgType>
<Content><![CDATA[%s]]></Content>
<ArticleCount>1</ArticleCount>
<Articles>
<item>
<Title><![CDATA[".$data[0]['title']."]]></Title>
<Description><![CDATA[".$data[0]['intro']."]]></Description>
<PicUrl><![CDATA[".$data[0]['pic']."]]></PicUrl>
<Url><![CDATA[".$data[0]['url']."]]></Url>
</item>
</Articles>
<FuncFlag>".$flag."</FuncFlag>
</xml> ";
echo $tpl;
}
}
function news_add($data){
$add = "";
foreach ($data as $k){
$add .= "<item>
<Title><![CDATA[".$k['title']."]]></Title>
<Description><![CDATA[".$k['intro']."]]></Description>
<PicUrl><![CDATA[".$k['pic']."]]></PicUrl>
<Url><![CDATA[".$k['url']."]]></Url>
</item> ";
}
return $add;
}
/*
function audio($fu,$tu,$data,$flag = 0){
$tpl = "<xml>
<ToUserName><![CDATA[".$fu."]]></ToUserName>
<FromUserName><![CDATA[".$tu."]]></FromUserName>
<CreateTime>".$_SERVER['REQUEST_TIME']."</CreateTime>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论