注释responsepassive.lib.php

src
mlg6veufz 2 months ago
parent 9cef04db85
commit c1eb3c2b85

@ -1,8 +1,24 @@
<?php <?php
namespace LaneWeChat\Core; namespace LaneWeChat\Core;
/**
* 发送被动响应
* Created by Lane.
* User: lane
* Date: 13-12-19
* Time: 下午3:01
* Mail: lixuan868686@163.com
* Website: http://www.lanecn.com
*/
class ResponsePassive{ class ResponsePassive{
/**
* @descrpition 文本
* @param $fromusername
* @param $tousername
* @param $content 回复的消息内容换行在content中能够换行微信客户端就支持换行显示
* @param $funcFlag 默认为0设为1时星标刚才收到的消息
* @return string
*/
public static function text($fromusername, $tousername, $content, $funcFlag=0){ public static function text($fromusername, $tousername, $content, $funcFlag=0){
$template = <<<XML $template = <<<XML
<xml> <xml>
@ -17,7 +33,14 @@ XML;
return sprintf($template, $fromusername, $tousername, time(), $content, $funcFlag); 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){ public static function image($fromusername, $tousername, $mediaId, $funcFlag=0){
$template = <<<XML $template = <<<XML
<xml> <xml>
@ -34,7 +57,14 @@ XML;
return sprintf($template, $fromusername, $tousername, time(), $mediaId, $funcFlag); 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){ public static function voice($fromusername, $tousername, $mediaId, $funcFlag=0){
$template = <<<XML $template = <<<XML
<xml> <xml>
@ -51,7 +81,16 @@ XML;
return sprintf($template, $fromusername, $tousername, time(), $mediaId, $funcFlag); 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){ public static function video($fromusername, $tousername, $mediaId, $title, $description, $funcFlag=0){
$template = <<<XML $template = <<<XML
<xml> <xml>
@ -70,7 +109,18 @@ XML;
return sprintf($template, $fromusername, $tousername, time(), $mediaId, $title, $description, $funcFlag); 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){ public static function music($fromusername, $tousername, $title, $description, $musicUrl, $hqMusicUrl, $thumbMediaId, $funcFlag=0){
$template = <<<XML $template = <<<XML
<xml> <xml>
@ -91,7 +141,15 @@ XML;
return sprintf($template, $fromusername, $tousername, time(), $title, $description, $musicUrl, $hqMusicUrl, $thumbMediaId, $funcFlag); 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){ public static function newsItem($title, $description, $picUrl, $url){
$template = <<<XML $template = <<<XML
<item> <item>
@ -104,9 +162,16 @@ XML;
return sprintf($template, $title, $description, $picUrl, $url); 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){ public static function news($fromusername, $tousername, $item, $funcFlag=0){
//多条图文消息信息默认第一个item为大图,注意如果图文数超过10则将会无响应
if(count($item) >= 10){ if(count($item) >= 10){
$request = array('fromusername'=>$fromusername, 'tousername'=>$tousername); $request = array('fromusername'=>$fromusername, 'tousername'=>$tousername);
return Msg::returnErrMsg(MsgConstant::ERROR_NEWS_ITEM_COUNT_MORE_TEN, '图文消息的项数不能超过10条', $request); 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); 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){ public static function forwardToCustomService($fromusername, $tousername){
$template = <<<XML $template = <<<XML
<xml> <xml>

Loading…
Cancel
Save