$url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=" . $tobkSTr;
$rawPost = [
"touser" => $appopenid,
"template_id" => "uSznBNtSI_cNBdJ2C0Xem5Brm4mbdzbv2X2xw",
"miniprogram_state" =>"developer",
"data" => [
"name2" => ["value" => "是"],
"phrase1" => ["value" => "人"]
]
];
$result = $this->m_post($url, $rawPost);
以下是php
function m_post($url , $jsonStr ) {
$type='json';
$ch = curl_init();
if($type=='json'){
$headers = array("Content-type: application/json;charset=UTF-8","Accept: application/json","Cache-Control: no-cache", "Pragma: no-cache");
$data=json_encode($jsonStr);
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($data)){
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS,$data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
错误信息如下:errcode":47001,"errmsg":"data format error hint: [oI85901954963]"
在线等.....
$url错了
传递参数要和模板上的参数类型一致才行
传参方式不对。本人不写php,不知道该怎么改,nodejs、java、python知道怎么改