Example #1
0
 /**
  * 菜单处理  click
  */
 public function clickMenu()
 {
     $data = M("wx_menu")->where(['id' => $this->request['eventkey']])->field("value,group")->find();
     if ($data['group'] == 'text') {
         ResponseInitiative::text($this->fromUsername, $data['value']);
     } elseif ($data['group'] == 'img') {
         $material = M("wx_material")->where(['id' => $data['value']])->find();
         if ($material) {
             $material['content'] = unserialize($material['content']);
             ResponseInitiative::news($this->fromUsername, $material['content']);
         } else {
             ResponseInitiative::text($this->fromUsername, '抱歉没找到对应的资源');
         }
     }
 }
Example #2
0
//发送语音
\LaneWeChat\Core\ResponseInitiative::voice($tousername, $mediaId);
//发送视频
\LaneWeChat\Core\ResponseInitiative::video($tousername, $mediaId, '视频描述', '视频标题');
//发送地理位置
\LaneWeChat\Core\ResponseInitiative::music($tousername, '音乐标题', '音乐描述', '音乐链接', '高质量音乐链接,WIFI环境优先使用该链接播放音乐', '缩略图的媒体id,通过上传多媒体文件,得到的id');
//发送图文消息
//创建图文消息内容
$tuwenList[] = array('title' => '标题1', 'description' => '描述1', 'pic_url' => '图片URL1', 'url' => '点击跳转URL1');
$tuwenList[] = array('title' => '标题2', 'description' => '描述2', 'pic_url' => '图片URL2', 'url' => '点击跳转URL2');
//构建图文消息格式
$itemList = array();
foreach ($tuwenList as $tuwen) {
    $itemList[] = \LaneWeChat\Core\ResponseInitiative::newsItem($tuwen['title'], $tuwen['description'], $tuwen['pic_url'], $tuwen['url']);
}
\LaneWeChat\Core\ResponseInitiative::news($tousername, $itemList);
/**
 * 被动发送消息
 */
//需要发给谁?
$fromusername = "******";
$tousername = "******";
$mediaId = "通过上传多媒体文件,得到的id。";
//发送文本
\LaneWeChat\Core\ResponsePassive::text($fromusername, $tousername, '文本消息内容');
//发送图片
\LaneWeChat\Core\ResponsePassive::image($fromusername, $tousername, $mediaId);
//发送语音
\LaneWeChat\Core\ResponsePassive::voice($fromusername, $tousername, $mediaId);
//发送视频
\LaneWeChat\Core\ResponsePassive::video($fromusername, $tousername, $mediaId, '视频标题', '视频描述');
Example #3
0
//发送语音
ResponseInitiative::voice($tousername, $mediaId);
//发送视频
ResponseInitiative::video($tousername, $mediaId, '视频描述', '视频标题');
//发送地理位置
ResponseInitiative::music($tousername, '音乐标题', '音乐描述', '音乐链接', '高质量音乐链接,WIFI环境优先使用该链接播放音乐', '缩略图的媒体id,通过上传多媒体文件,得到的id');
//发送图文消息
//创建图文消息内容
$tuwenList[] = array('title' => '标题1', 'description' => '描述1', 'pic_url' => '图片URL1', 'url' => '点击跳转URL1');
$tuwenList[] = array('title' => '标题2', 'description' => '描述2', 'pic_url' => '图片URL2', 'url' => '点击跳转URL2');
//构建图文消息格式
$itemList = array();
foreach ($tuwenList as $tuwen) {
    $itemList[] = ResponseInitiative::newsItem($tuwen['title'], $tuwen['description'], $tuwen['pic_url'], $tuwen['url']);
}
ResponseInitiative::news($tousername, $itemList);
/**
 * 被动发送消息
 */
//命名空间
use LaneWeChat\Core\ResponsePassive;
//需要发给谁?
$fromusername = "******";
$tousername = "******";
$mediaId = "通过上传多媒体文件,得到的id。";
//发送文本
ResponsePassive::text($fromusername, $tousername, '文本消息内容');
//发送图片
ResponsePassive::image($fromusername, $tousername, $mediaId);
//发送语音
ResponsePassive::voice($fromusername, $tousername, $mediaId);