-
Notifications
You must be signed in to change notification settings - Fork 316
message_template
thenbsp edited this page Mar 3, 2016
·
3 revisions
use Thenbsp\Wechat\Message\Template\Template;
// 定义一个模板
$template = new Template('zJ_a1LjbkZrHc9YaWeV7tmuUtI7LvlNvRPFdcmsprr4');
// 模板参数,每一个模板 ID 都对应一组参数
$template
->add('result', '恭喜您,中奖啦!')
->add('totalWinMoney', '中奖 5,000,000.00 元')
->add('issueInfo', '双色球2013023期')
->add('fee', '39.8 元')
->add('betTime', '2013-10-10 21:30')
->add('remark', '测试模板消息呢,别当真!', '#ff0000');
// 跳转链接
$template->setUrl('http://github.com/');
// 发给谁
$template->setOpenid('openid');
use Thenbsp\Wechat\Message\Template\Sender;
$sender = new Sender($accessToken);
try {
$msgid = $sender->send($template);
} catch (\Exception $e) {
exit($e->getMessage());
}
var_dump(sprintf('发送成功:#%s', $msgid));