I have problem with Instagram api using PHP. Instagram API url is following:
https://api.instagram.com/v1/media/popular?client_id=c32bb75ba2b449dc93b5461a84d9003e
Using this: https://github.com/cosenary/Instagram-PHP-API
with following code in my php script:
<?php
$instagram = new Instagram('c32bb75ba2b449dc93b5461a84d9003e');
$response = $instagram->getPopularMedia();
header('Content-Type: application/json');
echo json_encode($response, JSON_PRETTY_PRINT);
script execute sometimes longer then 40sec, sometimes no results.
Same problem is with simple call:
<?php
echo file_get_contents('https://api.instagram.com/v1/media/popular?client_id=c32bb75ba2b449dc93b5461a84d9003e')
With simple jquery AJAX request like this(on same server):
$.ajax({
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/media/popular?client_id=c32bb75ba2b449dc93b5461a84d9003e",
success: function(data) {
console.log(data);
}
});
result come always very fast.
I try this two ways on different servers and results are same. Also in PHP class I try use file_get_content instead CURL but everything is same.
Please help (with PHP).