-
Notifications
You must be signed in to change notification settings - Fork 22
群发消息
发送时确保该应用有相关的通讯录管理权限
<?php
use Stoneworld\Wechat\Broadcast;
use Stoneworld\Wechat\Message;
$appId = 'wx8ac123b21f53d7m5';
$secret = '4ZDHIETJ6e0oENlEkRhYwzWPTrkLdXedKcPcRjCkgQkuHtQTJ12ZhWHESowrJqS9';
$broadcast = new Broadcast($appId, $secret);
-
$broadcast->fromAgentId($agentId)->send($message)->toAll();
群发消息给所有粉丝 -
$broadcast->fromAgentId($agentId)->send($message)->toParty($toParty);
发送消息给部门 $toParty为 int (单一部门),array(1, 2, 4) (多个部门) -
$broadcast->fromAgentId($agentId)->send($message)->toTag($toTag);
发送消息给标签 $toTag为 string (单一标签),array(1, 2, 4) (多个标签) -
$broadcast->fromAgentId($agentId)->send($message)->to($user, $toParty, $toTag);
发送消息(多条件限制)
上述的 $message
可以是:
-
$message = Message::make('mp_news')->media_id('123dsdajkasd231jhksad');
群发mp_news图文 -
$message = Message::make('text')->content('CONTENT');
文本 -
$message = Message::make('voice')->media_id('123dsdajkasd231jhksad');
语音 -
$message = Message::make('image')->media_id('123dsdajkasd231jhksad');
图片 -
$message = Message::make('video')->media_id('123dsdajkasd231jhksad')->title('TITLE')->description('DESCRIPTION');
群发视频消息 -
群发news消息
use Stoneworld\Wechat\Messages\NewsItem;
$newsItem = new NewsItem();
$newsItem->title = '1212';
$newsItem->description = '3erer';
$newsItem->pic_url = '';
$newsItem->url = '';
$message = Message::make('news')->item($newsItem1)->item($newsItem2)->item($newsItem3);
-
$message = Message::make('image')->title('这是测试消息')->url('https://www.xxx.com');
//发送文本卡片消息