<?php
$appId = ‘wx45da7c65’; //这里需要给全吗?
$appSecret = ‘95dc5334cf’; //这里需要给全吗?
$form_id=$_GET[‘formid’];
$touser=$_GET[‘touser’];
$title=‘您在粉券圈中晒的贴子有了新评论了,点击即可回复’;
$content=$_GET[‘content’];
$page=$_GET[‘page’];
function http_request($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;
}
$url = “https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appId&secret=$appSecret”;
$res = json_decode(http_request($url));
$access_token = $res->access_token;
$template=array(
‘touser’=>$touser,
‘template_id’=>“vYKIcmPcG3uq3jHxB96TmIScyjM1dtXpE00bW6ALkYU”,
‘form_id’=>$form_id,
‘page’=>$page,
‘topcolor’=>"#7B68EE",
‘data’=>array(
‘keyword1’=>array(‘value’=>urlencode($title),‘color’=>’#000000’),
‘keyword2’=>array(‘value’=>urlencode($content),‘color’=>’#FF0000’),
‘keyword3’=>array(‘value’=>urlencode(date(‘y-m-d h:i:s’,time())),‘color’=>’#000000’),
)
);
$json_template=json_encode($template);
$url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=".$access_token;
$res1=json_decode(http_request($url,urldecode($json_template)));
print_r($res1);
if($res1 && ($res1->errcode == 0)) echo ‘发送成功’;
?>
我原来用这个代码开发其他的模板消息时,有的成功,即发送到通知消息中,但有的就怎么都发到客服消息中。包括现在,我也有另外的模板消息是运行对的。
你好,ios上显示错误并且mode='aspectFill’设置样式失败 请问 具体是什么问题?
麻烦给个相关的代码片段(https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/minicode.html),我们定位下问题