是否可以制作file_get_contents
即使发生错误,
否则很难调试。例如,假设您有以下代码:
$url = 'https://api.twitter.com/oauth/request_token';
$data = array();
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = @file_get_contents($url, false, $context);
var_dump($result);
var_dump($http_response_header);
这显示结果和 HTTP 标头为 NULL,但我想获得 Twitter 发回的实际消息(应该类似于),如果您尝试在浏览器Failed to validate oauth signature and token
中加载,这就是您得到的。https://api.twitter.com/oauth/request_token