我正在尝试查询Clash Royale的api以获取玩家和战队信息。当我设置CURLOPT_RETURNTRANSFER => FALSE
时,请求按预期方式工作,并且响应输出到浏览器中。但是,当我设置CURLOPT_RETURNTRANSFER => TRUE
时,它返回null。
以下URL是显示问题的演示: http://testing123.x10host.com/clashbot/
public function getDetails(){
$ch = curl_init();
$options = array(CURLOPT_URL => 'https://api.clashroyale.com/v1/clans/%23PQGLG8VC',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array('Accept: application/json'),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer $JWT'));
curl_setopt_array($ch, $options);
$reponse = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
var_dump(json_decode($response, true));
}