You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
5.6 KiB

2 months ago
<?php
include 'lanewechat.php';
$tousername = "用户和公众号兑换的OpenId";
$mediaId = "通过上传多媒体文件得到的id。";
\LaneWeChat\Core\ResponseInitiative::text($tousername, '文本消息内容');
\LaneWeChat\Core\ResponseInitiative::image($tousername, $mediaId);
\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 = "谁发给你的用户的openId";
$tousername = "你的公众号Id";
$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, '视频标题', '视频描述');
\LaneWeChat\Core\ResponsePassive::music($fromusername, $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\ResponsePassive::newsItem($tuwen['title'], $tuwen['description'], $tuwen['pic_url'], $tuwen['url']);
}
\LaneWeChat\Core\ResponsePassive::news($fromusername, $tousername, $itemList);
\LaneWeChat\Core\ResponsePassive::forwardToCustomService($fromusername, $tousername);
$openId = '用户和微信公众号的唯一ID';
\LaneWeChat\Core\UserManage::createGroup('分组名');
\LaneWeChat\Core\UserManage::getGroupList();
\LaneWeChat\Core\UserManage::getGroupByOpenId($openId);
\LaneWeChat\Core\UserManage::editGroupName('分组Id', '新的组名');
\LaneWeChat\Core\UserManage::editUserGroup($openId, '新的分组ID');
\LaneWeChat\Core\UserManage::getUserInfo($openId);
\LaneWeChat\Core\UserManage::getFansList($next_openId='');
\LaneWeChat\Core\UserManage::setRemark($openId, '新昵称');
\LaneWeChat\Core\UserManage::getNetworkState();
$redirect_uri = '获取CODE时发送请求和参数给微信服务器微信服务器会处理后将跳转到本参数指定的URL页面';
\LaneWeChat\Core\WeChatOAuth::getCode($redirect_uri, $state=1, $scope='snsapi_base');
$code = $_GET['code'];
\LaneWeChat\Core\WeChatOAuth::getAccessTokenAndOpenId($code);
\LaneWeChat\Core\Media::upload($filename, $type);
\LaneWeChat\Core\Media::download($mediaId);
$menuList = array(
array('id'=>'1', 'pid'=>'', 'name'=>'常规', 'type'=>'', 'code'=>'key_1'),
array('id'=>'2', 'pid'=>'1', 'name'=>'点击', 'type'=>'click', 'code'=>'key_2'),
array('id'=>'3', 'pid'=>'1', 'name'=>'浏览', 'type'=>'view', 'code'=>'http:
array('id'=>'4', 'pid'=>'', 'name'=>'扫码', 'type'=>'', 'code'=>'key_4'),
array('id'=>'5', 'pid'=>'4', 'name'=>'扫码带提示', 'type'=>'scancode_waitmsg', 'code'=>'key_5'),
array('id'=>'6', 'pid'=>'4', 'name'=>'扫码推事件', 'type'=>'scancode_push', 'code'=>'key_6'),
array('id'=>'7', 'pid'=>'', 'name'=>'发图', 'type'=>'', 'code'=>'key_7'),
array('id'=>'8', 'pid'=>'7', 'name'=>'系统拍照发图', 'type'=>'pic_sysphoto', 'code'=>'key_8'),
array('id'=>'9', 'pid'=>'7', 'name'=>'拍照或者相册发图', 'type'=>'pic_photo_or_album', 'code'=>'key_9'),
array('id'=>'10', 'pid'=>'7', 'name'=>'微信相册发图', 'type'=>'pic_weixin', 'code'=>'key_10'),
array('id'=>'11', 'pid'=>'1', 'name'=>'发送位置', 'type'=>'location_select', 'code'=>'key_11'),
);
\LaneWeChat\Core\Menu::setMenu($menuList);
\LaneWeChat\Core\Menu::getMenu();
\LaneWeChat\Core\Menu::delMenu();
$fansList = \LaneWeChat\Core\UserManage::getFansList();
$menuId = \LaneWeChat\Core\Media::upload('/var/www/baidu_jgylogo3.jpg', 'image');
if (empty($menuId['media_id'])) {
die('error');
}
$list = array();
$list[] = array('thumb_media_id'=>$menuId['media_id'] , 'author'=>'作者', 'title'=>'标题', 'content_source_url'=>'www.lanecn.com', 'digest'=>'摘要', 'show_cover_pic'=>'1');
$list[] = array('thumb_media_id'=>$menuId['media_id'] , 'author'=>'作者', 'title'=>'标题', 'content_source_url'=>'www.lanecn.com', 'digest'=>'摘要', 'show_cover_pic'=>'0');
$list[] = array('thumb_media_id'=>$menuId['media_id'] , 'author'=>'作者', 'title'=>'标题', 'content_source_url'=>'www.lanecn.com', 'digest'=>'摘要', 'show_cover_pic'=>'0');
$mediaId = \LaneWeChat\Core\AdvancedBroadcast::uploadNews($list);
$result = \LaneWeChat\Core\AdvancedBroadcast::sentNewsByOpenId($fansList['data']['openid'], $mediaId);