public function pushWxMsg(){
//1.获取到access_token
$access_token = '获取到access_token';
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;
$array = array(
'touser' => "用户openid", //用户openid
'template_id' => "在公众号下配置的模板id", //在公众号下配置的模板id
'url' => "https://www.imooc.com/course/qa/id/618/t/0?page=1", //点击模板消息会跳转的链接
'data' => array(
'first' => array('value' => "兼职平台签到测试开始", 'color' => "#FF0000"),
'keyword1' => array('value' => '兼职岗位小区门口卖西瓜', 'color' => '#FF0000'), //keyword需要与配置的模板消息对应
'keyword2' => array('value' => time(), 'color' => '#FF0000'), //keyword需要与配置的模板消息对应
'remark' => array('value' => "兼职平台签到测试结束,收到请钉钉回复一下", 'color' => "#FF0000"),
),
);
$json_template = json_encode($array);
// $res = $this->http_curl($url, 'post', 'json', $json_template);
$res = $this->curl_post($url, $json_template);
dump($res);
}
/**
* @param $url
* @param array $data
* @return mixed
* curl请求
*/
function curl_post($url, $data = array())
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// POST数据
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
返回的json数据只是表示你是否成功调用了模板消息接口,这跟用户收没收到你所发送的消息是两码事,所以你要看用户有没有收到这条模板消息,还是如你所说要解析XML数据才知道
左边导航“功能”“添加功能插件”里有个“模板消息”就是
通过 客服消息 发送的
我还没有试呢,先整体的听一遍,后面在细细回味
应该有,
楼上的问题解决了吗 求大神解答
不合法的corpid
这不是错误啊!这是你把变量打印出来了 你再看看到代码
模板消息推送事件中,需要再往下根据送达状态分类,要怎么实现?
$url 的accessToken变量这样可以赋值吗?
post数据需要jsonen_code()处理
我也没有看到 估计是他自己做着业务需要 或者 线下授课的时候 给付钱的同学讲的
页面授权
请问你的问题解决了吗,我现在也出现了这样的问题
代码不拿出来 怎么给你解决问题?
出问题了就贴代码,说是说不清楚的