Posted By

ginoplusio on 08/22/11


Tagged

php photos instagram pregmatchall


Versions (?)

How to use Instagram photos on your site


 / Published in: PHP
 

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

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.

  1. function getFollowgram($u) {
  2. // function read instagram feed through followgram.me service
  3. // thanks Fabio Lalli
  4. $url = "http://followgram.me/".$u."/rss";
  5. $s = file_get_contents($url);
  6. preg_match_all('#<item>(.*)</item>#Us', $s, $items);
  7. $ar = array();
  8. for($i=0;$i<count($items[1]);$i++) {
  9. $item = $items[1][$i];
  10. preg_match_all('#<link>(.*)</link>#Us', $item, $temp);
  11. $link = $temp[1][0];
  12. preg_match_all('#<pubDate>(.*)</pubDate>#Us', $item, $temp);
  13. $date = date("d-m-Y H:i:s",strtotime($temp[1][0]));
  14. preg_match_all('#<title>(.*)</title>#Us', $item, $temp);
  15. $title = $temp[1][0];
  16. preg_match_all('#<img src="([^>]*)">#Us', $item, $temp);
  17. $thumb = $temp[1][0];
  18. $ar['date'][$i] = $date;
  19. $ar['image'][$i] = str_replace("_5.jpg","_6.jpg",$thumb);
  20. $ar['bigimage'][$i] = str_replace("_5.jpg","_7.jpg",$thumb);
  21. $ar['link'][$i] = $link;
  22. $ar['title'][$i] = $title;
  23. }
  24. return $ar;
  25. }

Report this snippet  

You need to login to post a comment.