我的$ output输出为true,表示请求成功。我如何访问实际的响应主体?
add_action( 'init', 'get_login_details');
function get_login_details(){
$curl = curl_init();
$auth_token = 'somerandomtoken';
curl_setopt($curl, CURLOPT_URL, "https://api.ordercloud.io/v1/me");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer $auth_token'));
$output = curl_exec($curl);
print_r($output);
curl_close($curl);
}
答案 0 :(得分:0)
添加curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1)
,您的身体将保存到$output
。