From c1eb3c2b85a87419dd3dc13ffb719e4390ac4ecb Mon Sep 17 00:00:00 2001 From: mlg6veufz <3318209438@qq.com> Date: Mon, 30 Dec 2024 08:57:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8Aresponsepassive.lib.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/responsepassive.lib.php | 89 ++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 9 deletions(-) diff --git a/core/responsepassive.lib.php b/core/responsepassive.lib.php index 5fceaff..a85a367 100644 --- a/core/responsepassive.lib.php +++ b/core/responsepassive.lib.php @@ -1,8 +1,24 @@ @@ -17,7 +33,14 @@ XML; return sprintf($template, $fromusername, $tousername, time(), $content, $funcFlag); } - + /** + * @descrpition 图片 + * @param $fromusername + * @param $tousername + * @param $mediaId 通过上传多媒体文件,得到的id。 + * @param $funcFlag 默认为0,设为1时星标刚才收到的消息 + * @return string + */ public static function image($fromusername, $tousername, $mediaId, $funcFlag=0){ $template = << @@ -34,7 +57,14 @@ XML; return sprintf($template, $fromusername, $tousername, time(), $mediaId, $funcFlag); } - + /** + * @descrpition 语音 + * @param $fromusername + * @param $tousername + * @param $mediaId 通过上传多媒体文件,得到的id + * @param $funcFlag 默认为0,设为1时星标刚才收到的消息 + * @return string + */ public static function voice($fromusername, $tousername, $mediaId, $funcFlag=0){ $template = << @@ -51,7 +81,16 @@ XML; return sprintf($template, $fromusername, $tousername, time(), $mediaId, $funcFlag); } - + /** + * @descrpition 视频 + * @param $fromusername + * @param $tousername + * @param $mediaId 通过上传多媒体文件,得到的id + * @param $title 标题 + * @param $description 描述 + * @param $funcFlag 默认为0,设为1时星标刚才收到的消息 + * @return string + */ public static function video($fromusername, $tousername, $mediaId, $title, $description, $funcFlag=0){ $template = << @@ -70,7 +109,18 @@ XML; return sprintf($template, $fromusername, $tousername, time(), $mediaId, $title, $description, $funcFlag); } - + /** + * @descrpition 音乐 + * @param $fromusername + * @param $tousername + * @param $title 标题 + * @param $description 描述 + * @param $musicUrl 音乐链接 + * @param $hqMusicUrl 高质量音乐链接,WIFI环境优先使用该链接播放音乐 + * @param $thumbMediaId 缩略图的媒体id,通过上传多媒体文件,得到的id + * @param $funcFlag 默认为0,设为1时星标刚才收到的消息 + * @return string + */ public static function music($fromusername, $tousername, $title, $description, $musicUrl, $hqMusicUrl, $thumbMediaId, $funcFlag=0){ $template = << @@ -91,7 +141,15 @@ XML; return sprintf($template, $fromusername, $tousername, time(), $title, $description, $musicUrl, $hqMusicUrl, $thumbMediaId, $funcFlag); } - + /** + * @descrpition 图文消息 - 单个项目的准备工作,用于内嵌到self::news()中。现调用本方法,再调用self::news() + * 多条图文消息信息,默认第一个item为大图,注意,如果调用本方法得到的数组总项数超过10,则将会无响应 + * @param $title 标题 + * @param $description 描述 + * @param $picUrl 图片链接,支持JPG、PNG格式,较好的效果为大图360*200,小图200*200 + * @param $url 点击图文消息跳转链接 + * @return string + */ public static function newsItem($title, $description, $picUrl, $url){ $template = << @@ -104,9 +162,16 @@ XML; return sprintf($template, $title, $description, $picUrl, $url); } - + /** + * @descrpition 图文 - 先调用self::newsItem()再调用本方法 + * @param $fromusername + * @param $tousername + * @param $item 数组,每个项由self::newsItem()返回 + * @param $funcFlag 默认为0,设为1时星标刚才收到的消息 + * @return string + */ public static function news($fromusername, $tousername, $item, $funcFlag=0){ - + //多条图文消息信息,默认第一个item为大图,注意,如果图文数超过10,则将会无响应 if(count($item) >= 10){ $request = array('fromusername'=>$fromusername, 'tousername'=>$tousername); return Msg::returnErrMsg(MsgConstant::ERROR_NEWS_ITEM_COUNT_MORE_TEN, '图文消息的项数不能超过10条', $request); @@ -128,7 +193,13 @@ XML; return sprintf($template, $fromusername, $tousername, time(), count($item), implode($item), $funcFlag); } - + /** + * 将消息转发到多客服 + * 如果公众号处于开发模式,需要在接收到用户发送的消息时,返回一个MsgType为transfer_customer_service的消息,微信服务器在收到这条消息时,会把这次发送的消息转到多客服系统。用户被客服接入以后,客服关闭会话以前,处于会话过程中,用户发送的消息均会被直接转发至客服系统。 + * @param $fromusername + * @param $tousername + * @return string + */ public static function forwardToCustomService($fromusername, $tousername){ $template = <<