Reputation: 255
I have a basic php script that gets my last 30 instagram pictures. It just uses the media/recent endpoint url.. That works fine.
Looks like this
$userid = "ID";
$accessToken = "ACCESSTOKEN";
// Gets data
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}&count=30");
$result = json_decode($result);
And echo the output like this:
<?= $post->images->standard_resolution->url ?>
But how can I put the endpoint url's in a array and be able to echo comments and likes in the same way..
I've tried using instaphp, but it's really slow and creates an access token for each visit..
Upvotes: 0
Views: 1048
Reputation: 1756
If you have the full result set, you should be able to get things this way:
Likes:
<?= $post->likes->count ?>
<?= $post->likes->data->username ?>
<?= $post->likes->data->full_name ?>
<?= $post->likes->data->id ?>
<?= $post->likes->data->profile_picture ?>
Comments:
<?= $post->comments->count ?>
etc
Check out the documentation for the response: http://instagram.com/developer/endpoints/users/#get_users_media_recent
Upvotes: 1