搜尋
首頁微信小程式微信開發微信單圖文、多圖文推送、清單中排序

<?php

/**

* @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 = &#39;{

"touser":"&#39;.strval($openid).&#39;",

"msgtype":"text",

"text":

{

"content":"&#39;.$array[&#39;content&#39;].&#39;"

}

}&#39;;

$this->postService($json);

break;

case 2: $json = &#39;{

"touser":"OPENID",

"msgtype":"image",

"image":

{

"media_id":"MEDIA_ID"

}

}&#39;;

$this->postService($json);

break;

case 3: $json = &#39;{

"touser":"OPENID",

"msgtype":"voice",

"voice":

{

"media_id":"MEDIA_ID"

}

}&#39;;

$this->postService($json);

break;

case 4: $json = &#39;{

"touser":"OPENID",

"msgtype":"video",

"video":

{

"media_id":"MEDIA_ID",

"title":"TITLE",

"description":"DESCRIPTION"

}

}&#39;;

$this->postService($json);

break;

case 5: $json = &#39;{

"touser":"OPENID",

"msgtype":"music",

"music":

{

"title":"MUSIC_TITLE",

"description":"MUSIC_DESCRIPTION",

"musicurl":"MUSIC_URL",

"hqmusicurl":"HQ_MUSIC_URL",

"thumb_media_id":"THUMB_MEDIA_ID"

}

}&#39;;

$this->postService($json);

break;

case 6: $json = &#39;{

"touser":"OPENID",

"msgtype":"news",

"news":{

"articles": [

{

"title":"&#39;.$array[&#39;title1&#39;].&#39;",

"description":"&#39;.$array[&#39;description1&#39;].&#39;",

"url":"&#39;.$array[&#39;url1&#39;].&#39;",

"picurl":"&#39;.$array[&#39;picurl1&#39;].&#39;"

},

{

"title":"&#39;.$array[&#39;title2&#39;].&#39;",

"description":"&#39;.$array[&#39;description2&#39;].&#39;",

"url":"&#39;.$array[&#39;url2&#39;].&#39;",

"picurl":"&#39;.$array[&#39;picurl2&#39;].&#39;"

},

{

"title":"&#39;.$array[&#39;title3&#39;].&#39;",

"description":"&#39;.$array[&#39;description3&#39;].&#39;",

"url":"&#39;.$array[&#39;url3&#39;].&#39;",

"picurl":"&#39;.$array[&#39;picurl3&#39;].&#39;"

}

]

}

}&#39;;

$this->postService($json);

break;

}

}



public function postService($json){

$access_token = model(&#39;WeixinInterface&#39;)->getACCESS_TOKEN(330);

//Log :: write("客服接口获得的accessToken是".$access_token, log :: INFO);

$url = &#39;https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=&#39;.$access_token;

model(&#39;WeixinInterface&#39;)->getHttpResponsePOST($url,$json);



}



}

?>

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

MODEL中

public function Service($uid,$json){

self::$wxInterFace = M(&#39;WXInterFace&#39;,&#39;wxmenu&#39;);

$access_token = $this->getACCESS_TOKEN($uid);

$url = &#39;https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=&#39;.$access_token;

$this->getHttpResponsePOST($url,$json);

}

在ACTION中 

//图文回复

public function msgReturn(){

$json = &#39;{

"touser":"&#39;.strval($_SESSION[&#39;oauthopenid&#39;]).&#39;",

"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=&#39;.strval($_SESSION[&#39;oauthopenid&#39;]).&#39;",

"picurl":"http://dc.exweixin.com/data/upload/2014/1031/10/packet_1.jpg"

}

]

}

}&#39;;



//调用客服接口

$uid=330;

M(&#39;CustomService&#39;,&#39;wxmenu&#39;)->Service($uid,$json);

}

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

列表中排序、效果

1、

2、

3、

代码

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

 以上就是微信單圖文、多圖文推送、列表中排序的內容,更多相關內容請關注PHP中文網(www.php.cn)!


陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境