【发布时间】:2019-03-27 08:16:17
【问题描述】:
我正在使用旧的 Instagram API。 如果我使用 cUrl,它工作得很快,但我必须使用套接字或 file_get_contents() - 然后需要 10 多秒才能响应。
我尝试发送各种标头,例如“连接:关闭”并使用 http 1.0/1.1 - 但没有任何帮助。
这里的代码示例:
cUrl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.instagram.com/v1/users/self/?access_token=some_token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$res = curl_exec($ch);
curl_close($ch);
print_r($res);
file_get_contents()
$res = file_get_contents("https://api.instagram.com/v1/users/self/?access_token=some_token");
print_r($res);
【问题讨论】:
-
@zvi 我认为这不是 DNS 问题,因为当我使用 cUrl 时它运行得很快。我也尝试发送“连接:关闭”标头,但没有帮助。我正在运行 PHP 7.1
标签: php instagram file-get-contents instagram-api php-curl