微信多图文回复 php,初学微信开发,多图文回复咋就不行捏

完整的程序,屏蔽掉多图文部分是能用的

define("TOKEN","weixin");

$signature=$_GET['signature'];

$timestamp=$_GET['timestamp'];

$nonce=$_GET['nonce'];

$echostr=$_GET['echostr'];

$tmpArr=array(TOKEN,$timestamp,$nonce);

sort($tmpArr,SORT_STRING);

$tmpstr=implode($tmpArr);

$tmpstr=sha1($tmpstr);

if($tmpstr==$signature)

{

header('content-type:text');

echo $echostr;        //echo 为直接输出

}

else

{

echo "Error";

}

$postData=$HTTP_RAW_POST_DATA;

//echo "嗯呢1";

//2.将xml字符串转化成一个对象(处理xml数据包)

$xmlObj=simplexml_load_string($postData,"SimpleXMLElement",LIBXML_NOCDATA);

$touserName=$xmlObj->ToUserName;    //获取开发者微信号

$fromuserName=$xmlObj->FromUserName; //获取用户openid

$msgtype=$xmlObj->MsgType;    //消息的类型text

/*switch($msgtype)

{

//判断消息类型

case'text':*/

$content=trim($xmlObj->Content); //获取文本消息内容

// echo "嗯呢";

switch($content)

{

case'单图文':

$replyNewsMsg="

%s

         //news为图文消息意思

1

";

$title="是妹子吗";

$description="是就回复一下";

$picurl="http://jhbdeserves-img.stor.

$url="https://www.google.co.jp/search?q=%E5%A6%B9%E5%AD%90&safe=strict&biw=1366&bih=643&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjDq8nHjI_PAhUBnJQKHVTEDk8Q_AUIBigB#safe=strict&tbm=isch&q=%E6%9F%B3%E5%B2%A9";

echo sprintf($replyNewsMsg,$fromuserName,$touserName,time(),$title,$description,$picurl,$url);

break;

/*这里*****

case'多图文':

$newsArr=array(

array('Title'->"约吗?",

'Description'->"等你哦",

'PicUrl'->"http://jhbdeserves-img.stor.,

'Url'->"https://www.

)

array('Title'->"约吗?",

'Description'->"等你哦",

'PicUrl'->"http://jhbdeserves-img.stor.,

'Url'->"https://www.

)

);

foreach(  $newsArr as $item)

{

$itemtmpl="

";

$itemstr .=sprintf($itemtmpl,$item['Title'],$item['Description'],$item['PicUrl'],$item['Url']);

}

$replyNewsMsg="

%s

         //news为图文消息意思

2

".$itemstr."

";

echo sprintf($replyNewsMsg,$fromuserName,$touserName,time());

break;

*/

default:

break;

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值