sterhaar
10/1/2013 - 5:09 PM

Instagram Feed

Instagram Feed

<?php
    // Supply a user id and an client id
    $userid = "xxxxx"; 
    $clientid = "xxxxx"; // This can stay the same

    // 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);
         curl_close($ch); 
         return $result;
    }

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

<?php if($result) { ?>
    <?php foreach ($result->data as $post): ?>
        <img src="<?php $post->images->low_resolution->url; ?>" />
        <!-- <img src="<?php //$post->images->standard_resolution->url; ?>" /> -->
    <?php endforeach; ?>
<?php } ?>