用PHP写的。
echo "test";
$openid=$_GET["openid"];
$formId=$_GET["formId"];
$tableIndex=$_GET["tableIndex"];
$details=$_GET["details"];
$total=$_GET["total"];
$time=$_GET["time"];
$beizhu=$_GET["beizhu"];
$templateId="NDiqxPSdvpW8w7mWNbaZH18T8ihNjrzW7oby5t7IOmo";
$data=<<
{
"touser": "{$openid}",
"template_id": "{$templateId}",
"page": "index",
"form_id": "{$formId}",
"data": {
"keyword1": {
"value": "{$time}"
},
"keyword2": {
"value": "{$tableIndex}"
},
"keyword3": {
"value": "{$details}"
} ,
"keyword4": {
"value": "{$total}"
},
"keyword5": {
"value": "{$beizhu}"
}
},
"emphasis_keyword": "keyword4.DATA"
}
EOT;
function httpPost($data,$url){
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (compatible; MSIE 5.01;Windows NT 5.0)');
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_AUTOREFERER,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$tmpInfo=curl_exec($ch);
if(curl_errno($ch)){
return curl_errno($ch);
}
curl_close($ch);
return $tmpInfo;
echo $tmpInfo;
}
function httpGet($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
// 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
// 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
$appid =
$secret=
$gettoken="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
$result=httpGet($gettoken);
$arr=json_decode($result,true);
$token=$arr["access_token"];
$templateApi="https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={$token}";
$res=httpPost($data,$templateApi);
?>
微信小程序开发问题解答
微信小程序开发者回答:
感谢!
微信小程序开发者回答:
调试一下正式版看看报错:https://developers.weixin.qq.com/miniprogram/dev/api/debug/wx.setEnableDebug.html
本文网址:http://www.91bianli.com/kaifazhinan/75034.html