web development handcrafted

Lifestream Documentation and Debugging

14 Jun, 2009. Written by Tom Roggero

Hi everybody. As you might know there is a really useful plugin for WordPress called LifeStream from iBegin Labs.
What is it about? You can add a lot of sociable things. I will mention just a few examples, like your RSS feeds of any favourite blog, your Google Reader public sharing items, your Twitter updates, your last listened songs, your flickr photos, stumbleupon, digg, etc. It is a really complete plugin, in my thoughts, with Sociable, two of the best WP plugins.
I was doing my new lifestream site, when I started looking for this plugin. Because of documentation is not enough, I decided to share what I've learned about.
My idea was to list: last flickr picture, last 3 items shared from Reader, last tweet, and last 3 songs from

In official documentation there is a piece of code like this:

  1. $events = $lifestream->get_events(array('feed_types'=>array('twitter', 'facebook'), 'limit'=>10));

Well I will add some information about the variables you can pass to it.
Feed types as you can see is an array with string elements that correspond to your feeds. First of all, you have to set them up on WP Administration in order to work. And the list of possible feed_types:

  • amazon
  • backtype
  • blipfm
  • bliptv
  • blog
  • brightkite
  • cocomment
  • delicious
  • deviantart
  • digg
  • facebook
  • flickr
  • foodfeed
  • generic
  • github
  • goodreads
  • googlereader
  • hulu
  • identica
  • imdb
  • itunes
  • jaiku
  • kongregate
  • lastfm
  • librarything
  • magnolia
  • mixx
  • mobypicture
  • myepisodes
  • myspace
  • netflix
  • pandora
  • photobucket
  • picasa
  • plurk
  • readernaut
  • reddit
  • scrnshots
  • skitch
  • slideshare
  • smugmug
  • steam
  • stumbleupon
  • tumblr
  • twitpic
  • twitter
  • upcoming
  • viddler
  • vimeo
  • wikipedia
  • wpcodex
  • xboxlive
  • yelp
  • youtube
  • zooomr

limit is precisely how many items do you want to show.

And as limit, feed_types, are values of an array (the get_events passed variable), there are other important fields:
date_interval : it is string, so when you write it on the array you must write 'date_interval'=>'1 month'. Possible values are: X day, X month, X year, X week, etc... where X is an entire number and the word represents elapsed time. This is the one you must use to fix (by default it is just 1 month) when you cannot see any item of a feed.

That's all about building the array variable with items, to show them.
After that, you have to run inside the loop to print out the content.

  1. foreach ($events as $event){
  2. // echo text...
  3. }

The foreach function in php is read like "for each item on the $events array, called as $event do..."
So inside the {} (brackets) of foreach, you will use $event to refer the current item. Example:

  1. foreach ($events as $event){
  2. // this will print the SRC for <img alt="" /> of flickr
  3. // so you must do something like echo '<img src="'.NEXT_TEXT.'" alt="something" />';
  4. echo $event->data[0]['thumbnail'];
  6. // this is for twitter and some other stuff.
  7. // I dont recommend using title instead of description, because title's like "yourusername: yourtweet"
  8. echo $event->data[0]['description'];
  9. echo $event->data[0]['date']; // this will printout an unix timestamp number SEE NOTE BELOW
  11. // This shows the feed type label (set up on wp lifestream admin)
  12. echo $event->feed->options['feed_label'];
  14. // This one are for Google Reader
  15. echo $event->data[0]['link']; // shows the URL to be shared
  16. echo $event->data[0]['title']; // shows the title of the link
  18. // And for flickr I used
  19. echo $event->data[0]['thumbnail'];
  20. }

Also you can debug and check about other values with var_dump(); php function
Like in the example above:

  1. $events = $lifestream->get_events(array('feed_types'=>array('twitter'), 'date_interval'=>'1 year', 'limit'=>10));
  2. echo "<"."pre>";
  3. foreach ($events as $event){
  4. var_dump($event->data[0]);
  5. }
  6. echo "</"."pre>";

There you will know about how is the array built.

A common error you might see (because of iBegin typing error):

Parse error: syntax error, unexpected ';' in /document/root/file.php on line 10

To fix this you have to add a closing parenthesis.
Code with error:

  1. $events = $lifestream->get_events(array('feed_types'=>array('twitter'), 'number_of_results'=>1, 'break_groups'=>true);

Code without error:

  1. $events = $lifestream->get_events(array('feed_types'=>array('twitter'), 'number_of_results'=>1, 'break_groups'=>true));

Note for Twitter:
I had found a really good function to use for relative time, thanks to Zachstronaut.

Anything you need, just comment and I will reply ASAP.

Related posts /

  • Michle

    i was using this code “$events = $lifestream->get_events(array(‘feed_types’=>array(‘twitter’, ‘facebook’), ‘limit’=>10));” on sidebar.php file but I am getting this error:

    Fatal error: Call to a member function get_events() on a non-object in C:\wamp\www\wordpress\wp-content\themes\default-layout\sidebar.php on line 19

    Can u help me wher i m wrong


  • Tomas

    There is no syntax error in that piece of code. The problem is within your WordPress. I have the same code, and it is working on
    Check if your plugin was updated, and reactivated, I mean possibly it isn’t activated. $lifestream is a global variable, and it is called by the plugin.

  • Daniel

    Hello there,
    I think this is a great explanation for customizing lifestream output but I have a problem I put this code

    $events = $lifestream->get_events(array('feed_types'=>array('twitter'), 'limit'=>1));
    foreach ($events as $event){
    echo $event->data[0]['thumbnail'];

    But it doesn’t display anything I’ve tried with all the attributes (title, description, etc), and I don’t know why it doesn’t display anything.

  • Tomas

    I don’t think there is a thumbnail in the array of twitter in lifestream.

  • Pingback: Getting the WordPress Lifestream plugin to work on my blog » sacha chua :: living an awesome life

  • Pingback: Week ending September 12, 2010 » sacha chua :: living an awesome life

  • Pingback: Week ending September 19, 2010 » sacha chua :: living an awesome life

  • Chesley


    This is perhaps a very basic question, but I wanted to show my flickr updates as thumbnails instead of just links off to flickr. How would I do this?

    Many thanks,

  • Tomas

    echo '<div class="flickr">';
    foreach ($events as $event){
    echo '<img src="'.$event->data[0]['thumbnail'].'" alt="" />';
    echo '</div>';