解决方法
json_decode($response,true, 512, JSON_BIGINT_AS_STRING);
function hcurl($url,$type,$data='',$cookie=''){
//初始化
$curl = curl_init();
//设置抓取的url
curl_setopt($curl, CURLOPT_URL, $url);
//设置头文件的信息作为数据流输出
curl_setopt($curl, CURLOPT_HEADER, 1);
if($cookie){
//设置头文件的信息作为数据流输出
curl_setopt($curl, CURLOPT_COOKIE, $cookie);
}
// $header = array(
// 'Accept: application/json, text/javascript, */*; q=0.01'
// );
// curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
//设置获取的信息以文件流的形式返回,而不是直接输出。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
if ( $type == 'POST' ) {
//设置post方式提交
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
//执行命令
$response = curl_exec($curl);
// return $response;
// dump($response);
//关闭URL请求
curl_close($curl);
// $response = stristr($response,"zh-CN");
// $response = substr($response,5);
// $response = json_decode($response,true);
$num = strpos($response,"zh-CN");
if ($num) {
$response = substr($response,($num+5));
$login = strpos($response,"未登录");
if ($login>0) {
return '400';
}
$response = trim($response);
$response = json_decode($response,true, 512, JSON_BIGINT_AS_STRING);
}
return $response;
} 