Skip to content

veryrobert/instagram-fancybox

Repository files navigation

Instagram Fancybox PHP feed

I was on the look out for a simple instagram feed but couldn't find anything that was just a simple pull in of images.

Stuff I did find was:

Jquery instagram

Instagram API + Fancybox Simplified

[Spectragram – this seems really good actually] (http://lab.adrianquevedo.com/jquery-spectragram/)

I'm using the fancybox with the small change of limiting the default count of 20

$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}&count=6");

You'll need your Client id and Access code for this to work but you can use a third party to access them.

This will give you what you need

Here's the code

<?php
// Supply a user id and an access token
$accessToken = "YourAcessToken";
$userid = "UserID";


// Gets our 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);
// $result = 10;
curl_close($ch); 
return $result;

}

// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}&count=6");
$result = json_decode($result);

?>

<?php $items=6; $i=0; ?>


<?php foreach ($result->data as $post): ?>

<a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a> 

<?php endforeach ?>

About

A php solution for a simple instagram feed

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages