1

I'm working with old Instagram API. It works fast if I use cUrl, but I have to use sockets or file_get_contents() - then it takes 10+ seconds to response.

I have tried sending various headers like 'Connection: close' and using http 1.0/1.1 - but nothing helped.

Here code samples:

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);
  • See https://stackoverflow.com/questions/3629504/php-file-get-contents-very-slow-when-using-full-url – zvi Mar 27 '19 at 08:20
  • @zvi I think it's not DNS problem, because when I use cUrl it works fast. I have also tried sending 'Connection: close' header and that haven't helped. I'm running PHP 7.1 – Ruslan Arkhipov Mar 27 '19 at 08:30

1 Answers1

1

cUrl is always faster then file_get_contents() we also try this both in our site but the best way is cUrl.that response faster then file_get_contents().

if you set header like 'Connection: close' but you can't get response faster