Ruslan Arkhipov
Ruslan Arkhipov

Reputation: 11

Slow response of Insagram API when using file_get_contents()

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);

Upvotes: 1

Views: 423

Answers (1)

kartik radadiya
kartik radadiya

Reputation: 191

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

Upvotes: 1

Related Questions