记一次curl请求接口json格式数据无法转化

January 10, 2019

$url =  "http://jk-beta.htznbm.com/api/v1/site/f_book/address";

$headerArray =array("Content-type:application/json;","Accept:application/json");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($url,CURLOPT_HTTPHEADER,$headerArray);
$output = curl_exec($ch);
curl_close($ch);

if(preg_match('/^\xEF\xBB\xBF/',$output))
{
    $output = substr($output,3);
}
$info = json_decode(trim($output),true);

var_dump($info);

添加新评论