当我尝试从wordpress网站获取数据时,我得到了额外的条款。
function get_data($url)
{
$ch = curl_init();
$timeout = 20;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$uname=$_GET['uname'];
$pwd=$_GET['pwd'];
$root_url = "http://domain.com/";
$nonce_url = $root_url."api/get_nonce/?controller=auth&method=generate_auth_cookie";
$json = get_data($nonce_url);
$json_data = json_decode(substr($json,3), true);
// check that user is logged into WP
$nonce = $json_data['nonce']; // need to have an exception handler in case this fails
echo $json;
,输出为,
{"status":"ok","controller":"auth","method":"generate_auth_cookie","nonce":"3ca4ad3a80"}
如何从json数组中删除ï?¿这个额外的术语?