东莞企业网站建立报价,怎么做网站信息,品牌建设报告,旅游集团网站建设模板信息推送#xff1a;需要在后台开通了模板消息推送接口 PHP代码如下#xff1a;
?php
$appidwxxxxxxxxxxxxxxxxxx; //填写微信后台的appid
$appsecretxxxxxxxxxxxxxxxxxxxxxxxxx; //填写微信后台的appsecret
$TOKEN_URL…模板信息推送需要在后台开通了模板消息推送接口 PHP代码如下
?php
$appidwxxxxxxxxxxxxxxxxxx; //填写微信后台的appid
$appsecretxxxxxxxxxxxxxxxxxxxxxxxxx; //填写微信后台的appsecret
$TOKEN_URLhttps://api.weixin.qq.com/cgi-bin/token?grant_typeclient_credentialappid.$appid.secret.$appsecret;
$jsonfile_get_contents($TOKEN_URL);
$resultjson_decode($json,true);
$ACCESS_TOKEN$result[access_token]; #获取ACCESS_TOKEN在expire_time字段可以看到过期时间7200两个小时以秒为单位
$timesdate(Y-m-d H:i:s,time());
$nametest;//标题
$zutest1;//正文
//测试机账号
$openidoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
$templatearray(
touser$openid,
template_idxxxxxxxxxxxxxxxxxxxxxxxxxxx, //模板的id
urlhttp://weixin.qq.com/download,
topcolor#FF0000,
dataarray(
testarray(valueurlencode($name),color#00008B), //函数传参过来的name
test1array(valueurlencode($zu),color#00008B), //函数传参过来的zu
)
);
$json_templatejson_encode($template);
$urlhttps://api.weixin.qq.com/cgi-bin/message/template/send?access_token.$ACCESS_TOKEN;
$ch curl_init();
$dataurldecode($json_template);
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);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output curl_exec($ch);
curl_close($ch);
$arr json_decode($output, true);
echo $arr[errcode];
?
访问php文件网址则得到 任何程序错误以及技术疑问或需要解答的请扫码添加作者VX