微信單圖文、多圖文推送、列表中排序

/**
 * @author yinhuiying(改於)
 * @since version - 2014-10-31
 * @deprecated version - 2014-10-31
 * 騰訊客服接口
 */

class ServiceModel extends Model{
    
    /**
     * 客服接口(高級接口)
     * @param int $uid
     * @param String openid 微信唯一標識
     * @param String array 回覆數組內容
     * @param int type 類型 1表示文字回覆 2表示圖文回覆
     * */
    public function Service($openid,$array,$type){
        switch($type){
            case 1: $json = '{
                                    "touser":"'.strval($openid).'",
                                    "msgtype":"text",
                                    "text":
                                    {
                                         "content":"'.$array['content'].'"
                                    }
                                }';
            $this->postService($json);
            break;
            case 2: $json = '{
                                "touser":"OPENID",
                                "msgtype":"image",
                                "image":
                                {
                                  "media_id":"MEDIA_ID"
                                }
                            }';
            $this->postService($json);
            break;
            case 3: $json = '{
                                "touser":"OPENID",
                                "msgtype":"voice",
                                "voice":
                                {
                                  "media_id":"MEDIA_ID"
                                }
                            }';
            $this->postService($json);
            break;
            case 4: $json = '{
                                "touser":"OPENID",
                                "msgtype":"video",
                                "video":
                                {
                                  "media_id":"MEDIA_ID",
                                  "title":"TITLE",
                                  "description":"DESCRIPTION"
                                }
                            }';
            $this->postService($json);
            break;
            case 5: $json = '{
                                "touser":"OPENID",
                                "msgtype":"music",
                                "music":
                                {
                                  "title":"MUSIC_TITLE",
                                  "description":"MUSIC_DESCRIPTION",
                                  "musicurl":"MUSIC_URL",
                                  "hqmusicurl":"HQ_MUSIC_URL",
                                  "thumb_media_id":"THUMB_MEDIA_ID"
                                }
                            }';
            $this->postService($json);
            break;
            case 6: $json = '{
                                "touser":"OPENID",
                                "msgtype":"news",
                                "news":{
                                    "articles": [
                                     {
                                         "title":"'.$array['title1'].'",
                                         "description":"'.$array['description1'].'",
                                         "url":"'.$array['url1'].'",
                                         "picurl":"'.$array['picurl1'].'"
                                     },
                                     {
                                         "title":"'.$array['title2'].'",
                                         "description":"'.$array['description2'].'",
                                         "url":"'.$array['url2'].'",
                                         "picurl":"'.$array['picurl2'].'"
                                     },
                                     {
                                         "title":"'.$array['title3'].'",
                                         "description":"'.$array['description3'].'",
                                         "url":"'.$array['url3'].'",
                                         "picurl":"'.$array['picurl3'].'"
                                     }
                                     ]
                                }
                            }';
            $this->postService($json);
            break;
        }
    }
    
    public function postService($json){
        $access_token = model('WeixinInterface')->getACCESS_TOKEN(330);
        //Log :: write("客服接口獲得的accessToken是".$access_token, log :: INFO);
        $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token='.$access_token;
        model('WeixinInterface')->getHttpResponsePOST($url,$json);
    
    }
    

}

?>



---------------或者---------------------

MODEL中

    public function Service($uid,$json){
        self::$wxInterFace = M('WXInterFace','wxmenu');
        $access_token = $this->getACCESS_TOKEN($uid);
        $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token='.$access_token;
        $this->getHttpResponsePOST($url,$json);
    }


在ACTION中


//圖文回覆
    public function msgReturn(){
        $json = '{
                    "touser":"'.strval($_SESSION['oauthopenid']).'",
                    "msgtype":"news",
                    "news":{
                        "articles": [
                            {
                            "title":"大華雙十一購房狂歡節,團購優惠等你來!",
                            "description":"",
                            "url":"http://dc.exweixin.com/index.php?app=Dhcheap&mod=Index&act=index&aid=11",
                            "picurl":"http://dc.exweixin.com/data/upload/2014/1031/10/top_img_1.png"
                            },
                            {
                            "title":"一口價房源再享折上折",
                            "description":"",
                            "url":"http://dc.exweixin.com/index.php?app=RedPacket&mod=Coupon&act=welcome&uid=330",
                            "picurl":"http://dc.exweixin.com/data/upload/2014/1031/10/fixed_1.jpg"
                            },
                            {
                            "title":"我要搶紅包",
                            "description":"",
                            "url":"http://dc.exweixin.com/index.php?app=redPacket&mod=Welcome&act=welcome&uid=330",
                            "picurl":"http://dc.exweixin.com/data/upload/2014/1031/10/rob_1.jpg"
                            },
                            {
                            "title":"土豪排行榜",
                            "description":"",
                            "url":"http://dc.exweixin.com/index.php?app=RedPacket&mod=Index&act=ranking",
                            "picurl":"http://dc.exweixin.com/data/upload/2014/1031/10/ranking_1.jpg"
                            },
                            {
                            "title":"我的錢包",
                            "description":"",
                            "url":"http://dc.exweixin.com/index.php?app=RedPacket&mod=Index&act=person&openid='.strval($_SESSION['oauthopenid']).'",
                            "picurl":"http://dc.exweixin.com/data/upload/2014/1031/10/packet_1.jpg"
                            }
                        ]
                    }
                }';
    
        //調用客服接口
        $uid=330;
        M('CustomService','wxmenu')->Service($uid,$json);
    }




//----------------------------------//

列表中排序、效果

1、

2、

3、

代碼

<li class="count">{$i+$n}</li>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章