获取到的微信多客服聊天记录为空
程序员文章站
2022-03-05 17:45:15
...
微信多客服在多客服功能下有了一次改版,现在再去获取多客服的聊天记录获取的内容一直为空:{"recordlist":[]}
以下是我的代码
$data = ' {
"starttime" :1460304001,
"endtime" : 1460372401,
"pageindex" : 1,
"pagesize" : 1
}';
//请求聊天记录
$url = 'https://api.weixin.qq.com/customservice/msgrecord/getrecord?access_token='.$ACC_TOKEN;
$result = https_post($url,$data);
echo $result."
";
//取出得到的聊天记录
$jsoninfo = json_decode($result);
$json_data = $jsoninfo->recordlist;
function https_post($url,$data)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
echo "curl:".$data."
";
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if (curl_errno($curl)) {
return 'Errno'.curl_error($curl);
}
curl_close($curl);
return $result;
}
还是谢谢你
以下是我的代码
$data = ' {
"starttime" :1460304001,
"endtime" : 1460372401,
"pageindex" : 1,
"pagesize" : 1
}';
//请求聊天记录
$url = 'https://api.weixin.qq.com/customservice/msgrecord/getrecord?access_token='.$ACC_TOKEN;
$result = https_post($url,$data);
echo $result."
";
//取出得到的聊天记录
$jsoninfo = json_decode($result);
$json_data = $jsoninfo->recordlist;
function https_post($url,$data)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
echo "curl:".$data."
";
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if (curl_errno($curl)) {
return 'Errno'.curl_error($curl);
}
curl_close($curl);
return $result;
}
回复讨论(解决方案)
我觉得有两中可能 一时提交的数据结构变了 再不就是你access_token 过期了
我觉得有两中可能 一时提交的数据结构变了 再不就是你access_token 过期了
其实代码没问题,换了一个谷歌浏览器就成功了,搜狗浏览器太渣了,花了我半天的时间。。。。还是谢谢你
上一篇: php过滤微信表情符号