| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3472 人关注过本帖
标题:初学微信开发,多图文回复咋就不行捏
只看楼主 加入收藏
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
结帖率:76.92%
收藏
已结贴  问题点数:20 回复次数:6 
初学微信开发,多图文回复咋就不行捏
  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="<item>
            <Title><![CDATA[%s]]></Title>
            <Description><![CDATA[%s]]></Description>
            <PicUrl><![CDATA[%s]]></PicUrl>
            <Url><![CDATA[%s]></Url>
            </item>";
           $itemstr .=sprintf($itemtmpl,$item['Title'],$item['Description'],$item['PicUrl'],$item['Url']);   
          }
            $replyNewsMsg="<xml>
                <ToUserName><![CDATA[%s]]></ToUserName>
                <FromUserName><![CDATA[%s]]></FromUserName>
                <CreateTime>%s</CreateTime>
                <MsgType><![CDATA[news]]></MsgType>         //news为图文消息意思
                <ArticleCount>2</ArticleCount>            
                <Articles>".$itemstr."</Articles>
               </xml>";
          echo sprintf($replyNewsMsg,$fromuserName,$touserName,time());
          break;
         


[此贴子已经被作者于2016-9-16 00:44编辑过]

搜索更多相关主题的帖子: 开发 
2016-09-16 00:41
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
求大神给看看
2016-09-16 00:42
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
完整的程序,屏蔽掉多图文部分是能用的
<?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="<xml>
                                                            <ToUserName><![CDATA[%s]]></ToUserName>
                                                            <FromUserName><![CDATA[%s]]></FromUserName>
                                                            <CreateTime>%s</CreateTime>
                                                            <MsgType><![CDATA[news]]></MsgType>         //news为图文消息意思
                                                            <ArticleCount>1</ArticleCount>            
                                                            <Articles>
                                                            <item>
                                                                    <Title><![CDATA[%s]]></Title>
                                                                    <Description><![CDATA[%s]]></Description>
                                                                    <PicUrl><![CDATA[%s]]></PicUrl>
                                                                    <Url><![CDATA[%s]></Url>
                                                
                                                            </item>
                                                            </Articles>
                                                            </xml>";
                                            $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="<item>
                                            <Title><![CDATA[%s]]></Title>
                                            <Description><![CDATA[%s]]></Description>
                                            <PicUrl><![CDATA[%s]]></PicUrl>
                                            <Url><![CDATA[%s]></Url>
                        
                                     </item>";
                                $itemstr .=sprintf($itemtmpl,$item['Title'],$item['Description'],$item['PicUrl'],$item['Url']);   
                            }
                $replyNewsMsg="<xml>
                                            <ToUserName><![CDATA[%s]]></ToUserName>
                                            <FromUserName><![CDATA[%s]]></FromUserName>
                                            <CreateTime>%s</CreateTime>
                                            <MsgType><![CDATA[news]]></MsgType>         //news为图文消息意思
                                            <ArticleCount>2</ArticleCount>            
                                            <Articles>".$itemstr."</Articles>
                                            </xml>";
                                                              
                                          
                                                  
                                        echo sprintf($replyNewsMsg,$fromuserName,$touserName,time());
                                        break;
               */         
                                    default:
                                    break;
                                    
                   }
   
?>
2016-09-16 00:44
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:14 
慢慢看
2016-09-17 18:01
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
回复 4楼 tlliqi
蛤?
2016-09-18 21:23
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
求大婶们给看看。。
2016-09-18 21:54
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
解决了。。。
数组用"=>"而不是"->"赋值!
2016-09-18 23:25
快速回复:初学微信开发,多图文回复咋就不行捏
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018668 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved