代码部分
$url = ‘https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=’.$token['access_token’];
$data = array(
‘path’=>‘pages/logs/logs’,
‘width’=>280,
‘scene’=>$room_id.",".$rand_code,
‘line_color’=>’{“r”:“0”,“g”:“0”,“b”:“0”}’
);
$result = $this->curl($url,json_encode($data));
执行结果
{“errcode”:47001,“errmsg”:“data format error hint: [oUKtrA0772xa11]”}
请问是哪里不正确
47001通常是我们api收到的数据包不是预期的json数据格式。
留意到你直接把一个数组当作参数传入curl,而不是把数组做json_encode再传入
请自行检查,必要时建议把curl的post_data打印。
$params = [
'scene' => 'productid=' . $productionid,
'page' => 'pages/today/today',
'width' => '430',
'auto_color' => false,
'line_color' => ['r'=>'0','g'=>'0','b'=>'0'],
//'line_color' => "{'r':'0','g':'0','b':'0'}",
// 'line_color' => '{"r":"0","g":"0","b":"0"}'
];
json_encode($params, JSON_UNESCAPED_SLASHES)