小程序订阅信息的发送报错47001?请高手指点,感谢支持,我在此社区查过此问题无解。
发布于 6 年前 作者 li50 7173 次浏览 来自 问答
$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'){//json $_POST=json_decode(file_get_contents('php://input'), TRUE);
      $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]"

在线等.....
3 回复

传递参数要和模板上的参数类型一致才行

传参方式不对。本人不写php,不知道该怎么改,nodejs、java、python知道怎么改

回到顶部