treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Custom SimplePie Favicons

  • So I've been able to get all of the feed content with this code:


    // Require SimplePie
    require_once('simplepie.inc');

    // Initialize new feed
    $feed = new SimplePie(array(
    'http://twitter.com/statuses/user_timeline/18450439.rss',
    'http://iethan.posterous.com/rss.xml',
    'http://api.flickr.com/services/feeds/photos_public.gne?id=36044296@N07&lang=en-us&format=rss_200',
    'http://vimeo.com/iethan/likes/rss',
    'http://feeds.delicious.com/v2/rss/ethan.turkeltaub?count=15',
    'http://www.dopplr.com/traveller/iEthan/feed/96de3a3152674b4bbf7a0c67c8cfee1200c40acc5b88de152bac9a77bbcaecda'
    ));
    $feed->init();

    // Create a new array to hold data in
    $new = array();

    // Loop through all of the items in the feed
    foreach ($feed->get_items() as $item) {

    // Calculate 24 hours ago
    $yesterday = time() - (24*60*60);

    // Compare the timestamp of the feed item with 24 hours ago.
    if ($item->get_date('U') > $yesterday) {

    // If the item was posted within the last 24 hours, store the item in our array we set up.
    $new[] = $item;
    }
    }

    // Loop through all of the items in the new array and display whatever we want.
    foreach($new as $item) {
    echo '<div id=\"item\">';
    echo '<div class=\"date\">' . $item->get_date('M j, Y') . ' - ' . $item->get_date('H:i:s') . '</div>';
    echo '<div class=\"content\"><a href=\"' . $item->get_permalink() . '\">' . $item->get_title() . '</a></div>';
    echo '</div>';
    }


    Now, for each of those feeds, I need to designate a custom favicon. How would I do this?
  • I don't understand what you mean by "designate a custom favicon". Each feed has a favicon. You can access this using $item->feed->get_favicon() if that is what you mean.

    To display the favicon in html you can use:
    echo '<img src=\"' . $item->feed->get_favicon() . '\" alt=\"\" />';	
  • I mean so that instead of the normal favicon, I can make it so that certain feeds have favicons I have on my site. So, say it was a Twitter update. I would need to get that icon from my site, instead of the normal one.
  • Anybody find an answer to this? I would love it if I could have custom icons for each different feed... I've been searching everywhere, but the only thing I could find was in this crappy yahoo group forum: http://tech.groups.yahoo.com/group/simp ... ssage/2184

    Any help would be greatly appreciated, I'm starting to go crazy!!! Thanks :)
  • Anyone have even the slightest idea on how to do this??