Return to Snippet

Revision: 50444
at August 22, 2011 17:43 by ginoplusio


Initial Code
function getFollowgram($u) {
    // function read instagram feed through followgram.me service
    // thanks Fabio Lalli
    $url = "http://followgram.me/".$u."/rss";
    $s = file_get_contents($url);
    preg_match_all('#<item>(.*)</item>#Us', $s, $items);
    $ar = array();
    for($i=0;$i<count($items[1]);$i++) {
        $item = $items[1][$i];
        preg_match_all('#<link>(.*)</link>#Us', $item, $temp);
        $link = $temp[1][0];
        preg_match_all('#<pubDate>(.*)</pubDate>#Us', $item, $temp);
        $date = date("d-m-Y H:i:s",strtotime($temp[1][0]));
        preg_match_all('#<title>(.*)</title>#Us', $item, $temp);
        $title = $temp[1][0];
        preg_match_all('#<img src="([^>]*)">#Us', $item, $temp);
        $thumb = $temp[1][0];
        $ar['date'][$i] = $date;
        $ar['image'][$i] = str_replace("_5.jpg","_6.jpg",$thumb);
        $ar['bigimage'][$i] = str_replace("_5.jpg","_7.jpg",$thumb);
        $ar['link'][$i] = $link;
        $ar['title'][$i] = $title;
    }
    return $ar;
}

Initial URL
http://www.barattalo.it/2011/08/18/how-to-use-instagr-am-photos/

Initial Description
Thanks to followgram.me you can read a public feed with your photos. Use this code to retrieve your Instagr.am photos and use them on your web.

Initial Title
How to use Instagram photos on your site

Initial Tags
php

Initial Language
PHP