Exemple #1
0
//发送语音
\XYWeChat\ResponseInitiative::voice($tousername, $mediaId);
//发送视频
\XYWeChat\ResponseInitiative::video($tousername, $mediaId, '视频描述', '视频标题');
//发送地理位置
\XYWeChat\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[] = \XYWeChat\ResponseInitiative::newsItem($tuwen['title'], $tuwen['description'], $tuwen['pic_url'], $tuwen['url']);
}
\XYWeChat\ResponseInitiative::news($tousername, $itemList);
/**
 * 被动发送消息
 */
//需要发给谁?
$fromusername = "******";
$tousername = "******";
$mediaId = "通过上传多媒体文件,得到的id。";
//发送文本
\XYWeChat\ResponsePassive::text($fromusername, $tousername, '文本消息内容');
//发送图片
\XYWeChat\ResponsePassive::image($fromusername, $tousername, $mediaId);
//发送语音
\XYWeChat\ResponsePassive::voice($fromusername, $tousername, $mediaId);
//发送视频
\XYWeChat\ResponsePassive::video($fromusername, $tousername, $mediaId, '视频标题', '视频描述');
Exemple #2
0
<?php

ini_set("display_errors", 1);
include './../XYWeChat.php';
$tousername = "******";
//发送客服文本
if ($_GET['action'] == 'kefuwenben') {
    //发送客服内容
    $arr = \XYWeChat\ResponseInitiative::text($tousername, '文本消息内容sdf');
    print_r($arr);
} elseif ($_GET['action'] == 'kefutuwen') {
    $item = array('title' => 'title', 'description' => 'description', 'url' => 'http://c.hiphotos.baidu.com/zhidao/wh%3D600%2C800/sign=955679078b82b9013df8cb3543bd854f/71cf3bc79f3df8dc8baaddb1cc11728b4710287e.jpg', 'picurl' => 'www.baidu.com');
    $test = \XYWeChat\ResponseInitiative::news($tousername, array($item));
    print_r($test);
} elseif ($_GET['action'] == 'uploadNews') {
    $neir = file_get_contents('html.txt');
    //echo $neir;
    $item = array(array('thumb_media_id' => '_5yNFt1geWI0O195hppQ-cVuoZfUU5eEhEddkBFsQQooZgFQE0KiTy8scqfYPkNg', 'author' => '作者' . time(), 'title' => '标题', 'content' => $neir, 'content_source_url' => 'www.lanecn.com', 'digest' => '摘要', 'show_cover_pic' => '1'));
    print_r($item);
    $test = \XYWeChat\AdvancedBroadcast::uploadNews($item);
    print_r($test);
    //YsshQHBKxFcrIEYtwWrn-bO5JQW-Yhi8xZNexWNR7MGYPAtHz5r6VNRE77QN7KE2
    //m9C0hzxrpfG1X7iIqEchK7MV7_aqxQxQN_sGLcX0zYqjHxQMHk4Jc9j5tr0KCKzv
} elseif ($_GET['action'] == 'preview') {
    //$neir = file_get_contents('html.txt');
    //echo $neir;
    $item = "m9C0hzxrpfG1X7iIqEchK7MV7_aqxQxQN_sGLcX0zYqjHxQMHk4Jc9j5tr0KCKzv";
    $test2 = \XYWeChat\AdvancedBroadcast::preview($tousername, 'mpnews', $test['media_id']);
    print_r($test2);
}