SSWI — When in doubt, buff it out.

Lifestream, ala WordPress,

Written in Frisco, TX on November 26, 2006 and tagged with .

65 Comments, why not add one?

My Flickr Stream

UPDATE: I have a fix for the time problems.  You need to add the following code right after line 93 of stream.php (that line should look like this: $date = strtotime( substr( $item['pubdate'], 0, 25 ) );):
$date -= 3600*N;
Where N is how many hours you need to remove.  If you need to add time, then change the -= to +=

I really like the concept of Jermey Keith’s Lifestream, and after reading Mike’s cry in the dark for something akin to this, that caches, I decided to create a plugin/page template combo that replicated Jeremy’s code, but using only bits and bots that are present in WordPress.

This doesn’t really address much of Mike’s needs… I am pretty sure I could easily wedge this data into an RSS feed if I wanted to, but I don’t really care to at the moment.  Maybe tomorrow.  What this does do is use the bundled versions of snoopy and magpieRSS to query and render the content.

This gives us built in caching, and a mechanism for retrieving the data that gets around host restrictions on fopen and the like.

There are currently two caveats to this code:

  1. Twitter doesn’t have a valid RSS feed, so magpie chokes on it.  A quick trip through feedburner fixes that right up.
  2. I can’t for the life of me, get my del.icio.us feed to display correctly.  A trip through Feedburner couldn’t even fix it.

So there swell, I have a Lifestream, now I just need to stay on top of updating it.  If you would like to take it for a spin, you can download the code, sans CSS, over here


personal avatar

kristin, on March 1, 2007

I love the idea of this. I’ve never seen it before. I’ll definitely be trying it out. Thanks!

personal avatar

Michael Heilemann, on March 1, 2007

This is great; i hope ;) — How does it store the data?

The reason I’m looking for something which can store the data in the post table, is so that it’s easy to use the traditional WP tools for retrieving and displaying them, as well as searching and what not.

personal avatar

Michael Heilemann, on March 1, 2007

PS: Is the time set right in your lifestream? You need to go to bed sooner ;)

personal avatar

Derek Punsalan, on March 1, 2007

Now that is cool. One of the more interesting bits of code that I’ve seen in the past week. Must. Try. To. Find. Time. I’ll definitely play around with this.

personal avatar

matthew, on March 1, 2007

Im getting an error;

Fatal error: Undefined class name ‘self’ in /usr/home/path/to/life.php on line 29

which is

self::install();

Using some Googleing it seems that maybe this is because my server is php 4. Im still looking into it, but any ideas?

personal avatar

Chris J. Davis, on March 1, 2007

Hey Mike,

This is great; i hope ;) — How does it store the data?


Yeah, as I was saying in the post, this doesn’t really meet your requirements. The content is saved as a serialized RSS object in the options table. I could look into saving it to the post table in the future.

Matthew,

I managed to fix it by changing all occurrences of self:: to classname:: - for example in lifemanager.php line 39: self::cleanStreams(); becomes lifeadmin::cleanStreams(); because the class is lifeadmin as defined on line 11 of that file. I did this across all the files and it seems to work.


I was just about to suggest that. I had though self was a valid construct for PHP 4, guess not. As for the timezone thing, I don’t think it is actually working, so don’t sweat it. I will be releasing an update that finds the time another way.

personal avatar

Michael Heilemann, on March 1, 2007

Seems I’m on PHP4 as well. Damn. I’ll have to go through the files and change the self thingie as well.

personal avatar

kristin, on March 1, 2007

It doesn’t seem to do anything if I add another stream that isn’t one of the defaults. I even tried manually adding another line to the options table in the db.

also… i noticed there are no rss_* lines in my options table either….

It works… just not for any other feeds I add.

personal avatar

kristin, on March 1, 2007

It seems like it wasn’t liking the atom feed, so I ran it through feed burner but its still not working. Not sure what is wrong with it, but if I switch the feed out and replace it with another feed it works.

I’ll keep playing with it and let u know what I find :)

personal avatar

kartooner, on March 1, 2007

Awesome Chris. I was wondering when you’d release the code for this after your mentioning it on Twitter (yes, I’m that in tune with your life…. *cue spooky music*).

Anyways, it would be cool to have this data stored somewhere (or archived) for that matter, but in the internim it looks nifty, so yeah, thanks!

personal avatar

Chris J. Davis, on March 1, 2007

kristin,

It seems like it wasn’t liking the atom feed, so I ran it through feed burner but its still not working. Not sure what is wrong with it, but if I switch the feed out and replace it with another feed it works.


Yeah, magpie chokes on ATOM feeds for some reason. From a once over of the code, it should handle them, but something is b0rken.

Also magpie is a stickler for well formed feeds, so if there is an error in a feed it won’t be displayed. That is what is happening with Twitter’s feed.

Kartooner,

Anyways, it would be cool to have this data stored somewhere (or archived) for that matter, but in the internim it looks nifty, so yeah, thanks!


I am not sure what the use of that would be, but that hasn’t stopped me from coding things in the past, so why let it stop me now?

This is very much a 1.0 release, expect better error handling, and feed handling in the next major release. There will be a quick error fix release today sometime I imagine.

personal avatar

Chris, on March 1, 2007

This is great. The only problem that I have is that I’m unable to change the date. It’s set to American/Eastern or something, but I wanna change it to Australia/Sydney, but it doesn’t show the date/times I want. Any ideas on how to sort this out?

Also, what should I be looking for in the database to delete all the data?

personal avatar

Chris, on March 1, 2007

I tried change the time settings, but it didn’t work. Everything is still showing the same times as before.

Oh, and thanks for the heads up on the control panel.

personal avatar

Sean, on March 1, 2007

so, this is probably a total n00b question… but… i just installed it all and had two problems.

1) why is it only showing your stuff chris? even though my info is in there.

2) i’m getting this error:

Warning: array_slice() [function.array-slice]: The first argument should be an array in /home/.desi/seanmcdonaldhome/seanmcdonald.ca/wp-content/themes/Cutline/stream.php on line 81

Warning: Invalid argument supplied for foreach() in /home/.desi/seanmcdonaldhome/seanmcdonald.ca/wp-content/themes/Cutline/stream.php on line 83

personal avatar

Sean, on March 1, 2007

well, i figured out why it was showing chris’ stuff and not mine, found that in the file - although, i guess that means the admin page doesn’t work?

still getting that array_slice() [function.array-slice] error i mentioned in my previous comment.

personal avatar

Sean, on March 1, 2007

i apologize for being the equivalent of spam on here today… i didn’t read the two caveats that you put up Chris.

i put the twitter feed through feedburner and the issue went away, although my lifestream has some strange and random dates going backwards right now. i’ll play with it some more.

thanks for this.

seanmcdonald.ca/lifestream

personal avatar

Chris J. Davis, on March 1, 2007

No problem Sean, I hope your experimentations go well.

personal avatar

Chris, on March 1, 2007

Thanks for the update Chris. That extra line of code works like a charm. :D Now it doesn’t look like I’m on the net in the early hours of the morning.

personal avatar

kartooner, on March 1, 2007

I am not sure what the use of that would be, but that hasn’t stopped me from coding things in the past, so why let it stop me now?

Oh, just to have an archived life I suppose.

Hey, would it be possible to make it compatible with Ma.gnolia’s feed in the future release? I use that over Delicious, mainly because of the functionality of it over anything else.

personal avatar

Michael Heilemann, on March 1, 2007

Yeah, I’m definitely in it to archive my life to the extend possible. Also, by storing the lifestream as posts, you can easily use all the tools available to normal posts on them.

And the cross-referencing possibilities are endless! :D

personal avatar

Gunnar Hafdal, on March 1, 2007

I really like this plugin and I also like this idea of archiving ones life. The only thing I saw as a problem was on my side actually because I don’t put title’s on my flickr photos so that comes up as an empty pink box :)

Terrific idea, good work on the plugin, it just needs a little bit of extra love and it will be a great thing.

personal avatar

Dennis Larsen, on March 1, 2007

I must be doing something terribly wrong.

a) I get two headers on my lifestream page.

b) The stream is placed at the bottom.

Any idea what I’m doing wrong? Sorry for being a noob here…

personal avatar

Chris J. Davis, on March 1, 2007

Mike,

Yeah, I’m definitely in it to archive my life to the extend possible.


I get it Heilemann, I get it. I will do my best to whip something up for you, as I always do. :)

Gunnar,

Terrific idea, good work on the plugin, it just needs a little bit of extra love and it will be a great thing.


So, what are you thinking exactly when you say “a little bit of extra love”? I need details people!

Dennis,

a) I get two headers on my lifestream page.

b) The stream is placed at the bottom.


Off the top of my head, I would think it is the fact that the template file stream.php is set up for my theme, and not yours. Experiment with working the lifestream code into one of your existing page templates and see how that works.

personal avatar

Sean, on March 1, 2007

well, mine is up and running… thanks Chris.

the only issue i’m having is with time, and i think it’s not hte plugin, but my accounts… cocomment is off by hours and i’ve check my settings. del.ico.us seems really slow at coming it.

other than that, it’s great…

archiving would be cool.

personal avatar

Gil Creque, on March 1, 2007

You don’t know how long I’ve been thinking about something like this. Thanks for a wonderful plugin. I second the idea of this being put into a database and then presenting it form their. It would allow endless cross referencing and a search ability. For some reason my del.icio.us is only posting a link I saved about 6 months. It’s the last item in the feed and it’s indicated it was posted yesterday (but in the feed it says March). Other then that I realized for some reason flickr’s time was behind 3 hours but everything else was 5 hours ahead so I added a little something to your time stamp update above (also the parentheses and colon in your example through me off for a sec) .

$date = strtotime( substr( $item[‘pubdate’], 0, 25 ) );

if( $name == “life_flickr”) {

$date += 3600*3;

}

else {
$date -= 3600*5;
 }

Thanks again Chris.

personal avatar

Chris, on March 1, 2007

For some reason my del.icio.us is only posting a link I saved about 6 months. It’s the last item in the feed

Yeah, I get this too. I’ve seen a few people getting it to work properly, though I don’t get how.

personal avatar

alvin, on March 1, 2007

When I first stumbled across JK’s stream, I wonder how long will it takes for someone to write a WP plugin of the equivalent. Well it certainly doesn’t take too long, does it?!

Nice work. Although I know a couple of people have had problem with magpieRSS’s caching because of the lack of file locking mechanism. That could lead to cache corruption that can sometimes occur when there are a large amount of concurrent users trying to read and write to your cached rss data.

But I wont take the credit away from you, nice job!

FYI: You can try looking into pear’s cache_lite in the future for better caching capability.

personal avatar

Sean, on March 1, 2007

chris… i’m sure this is already possible in the code, but i couldn’t quite figure where to make the change.

a good addition would be to control how many days show - when i figure it out i’ll likely keep it to the last week.

if it were archived, i suppose you could go back and check out previous weeks.

personal avatar

Brandon, on March 1, 2007

this is a great idea, but I am having a lot of problems installing the actual script, even after changing self to lifeadmin.

personal avatar

matthew, on March 1, 2007

Brandon, not ALL ‘self’s change to lifeadmin, just those within that class. The other ‘self’s change to whatever class they are within.
What I showed was just an example.

personal avatar

Brandon, on March 1, 2007

Thanks matthew.

Perhaps an updated version for those of us on php 4 would be incredibly helpful for us :)

personal avatar

Sean, on March 1, 2007

i just found out from feedburner that once you put feeds through their format conversion, they can’t garuntee what timezone it will come out representing.

i’ve tried diong this to manage the times:

$date = strtotime( substr( $item[‘pubdate’], 0, 25 ) );

if( $name == “life_flickr”) {
$date += 3600*3;
}
else if( $name == “life_delicious”) {
$date += 3600*1;
}
else {
$date -= 3600*6;
}

this is the point where it becomes obvious i’m a hack at php and i start messing things up… it’s working to some extent, but some of the times still aren’t working 100% not even sure if there’s anything that could be done about this in the actually plugin.

personal avatar

Gil Creque, on March 1, 2007

I did the same exact thing Sean. I had to add more code for twitter’s time (when it finally came back up yesterday and I was able to get it to run thru feedburner).

if( $name == “life_flickr”) {

$date += 3600*3;

}

elseif( $name == “life_twitter”) {

$date += 3600;

}

else {
$date -= 3600*5;
}

personal avatar

Gil Creque, on March 1, 2007

Chris, something is wrong with the gravatars on here. ijust got the completely wrong one next to my name (I should be the Space Invader guy).

personal avatar

Chris J. Davis, on March 1, 2007

Thanks for the time tips everyone, and Gil, Gravatars are all screwed up everywhere. That isn’t something I have control over.

personal avatar

Sean, on March 1, 2007

i just noticed that lifestream doesn’t cache entries from last.fm - it only keeps track of the last 10 songs. so, if you’ve played 5 songs today, it will only have 5 songs from the day before - or 3 songs from yesterday and 2 songs from the day before that…

so basically, in your entire lifestream it will only show the last 10 songs you’ve played.

personal avatar

bv, on March 1, 2007

i’m almost there… i think(?)

i am however getting two errors:

1. Fatal error: Call to undefined function: install() in /go/wp-content/themes/281/life.php on line 29

2. Fatal error: Call to undefined function: get_option() in /go/wp-content/themes/281/life.php on line 27

any help is greatly appreciated! i can’t figure this on out.
thanks!

personal avatar

Slaff, on March 1, 2007

First of all, this is great plugin! Thanks for that. I just downloaded and i’m trying to install it in of mine blogs.

I’ve met simular problems as matthew above with undefined class ‘self’. But it resolves, as was sayed, replacing ‘self’ by ‘lifeadmin’ plugin works ok.

Other problem is a function ‘date_default_timezone_set’ in stream.php which is avaible only in php5 and above. Anyway, i’ve commented it out and seems to work fine for me.

Sorry for my bad english and tnanks again!

personal avatar

bv, on March 1, 2007

ok, i have everything working but the date. when the existing text is in place:

date_default_timezone_set(“America/Eastern”);

i get a fatal error. are there specific parameters i should put in like GMT or what?

any help is VERY appreciated!

thanks for the great plugin!

personal avatar

bv, on March 1, 2007

also, last one i promise. is there a way to set the number of days or time you want the posts to show?

thank you!!

personal avatar

tozé, on March 1, 2007

i got the Fatal error: Call to undefined function: install() in /home/toze/public_html/texto/wp-content/themes/minimalistic/life.php on line 29 and i don’t think i’m php-savvy enough to solve it.

can anyone shed some light on this please?

personal avatar

Phil Bowell, on March 1, 2007

I’m just testing this out, I get an error on line 29 also. I made the lifeadmin:: changes that were suggested earlier up the comments, but it now says I have an undefined function instal() on the same line. Any help, I’m a complete php novice.

personal avatar

bv, on March 1, 2007

i believe this has to do with the php4 issue. i had a similar problem which was solved by the self/lifeadmin issue on a previous post.

i’m not a superstar w/ php either so i could be wrong. any have any to add?

and when someone has a spare second can i get an answer for the time issue i posts a couple of posts back?

thanks so much!

personal avatar

franky, on March 1, 2007

Lots of PR love. Just a detail, but why not add rel="nofollow" around line 129 in stream.php ?

personal avatar

bv, on March 1, 2007

franky. dumb question from a relative newby but what does that accomplish? might need to add it to mine(?)

also, do you know why i get an error with the time phrase:

date_default_timezone_set(“America/Eastern”);

on line 73?

thanks!

personal avatar

Alec, on March 1, 2007

Any instructions on how to install this? I have the plug activated and all i get is a blank screen under manager

personal avatar

Stickrod, on March 1, 2007

Anyone figure out the del.icio.us issue yet? Perplexing.

personal avatar

Weiran, on March 1, 2007

My Flickr feed seems to be on US time instead of GMT, it would be nice if we could set manually an amount of hours to +/- from the feeds time incase they don’t follow my local timezone?

personal avatar

Karsten, on March 1, 2007

Will there be a final/stable version for public download? I love the idea around the lifestream feature but I am hardly a php coder…

personal avatar

Karsten, on March 1, 2007

Could somebody send me his fixed version of the plugin? Somehow I can’t get it installed or fixed. Thanks a million!

personal avatar

Joe Whitsitt, on March 1, 2007

I finally got it working and I am quite thankful.

I don’t know if you are taking feature requests, but…

A storage type thing to keep more than just the 10 last.fm tracks.

ability to isolate one feed and display them all together? ajax?

Consider using API?

personal avatar

tomeppy, on March 1, 2007

Thanks for this! Got it working, but just see weirdness with my Twitter and Delicious feeds. Nothing that can’t be fixed.

Very cool.

personal avatar

Karsten, on March 1, 2007

Sorry that I spammed this entry so utterly. Again, if you lads got a fixed version, could please send it?
My email’s: bombayvindaloo@gmail.com

personal avatar

bv, on March 1, 2007

Gunnar Hafdal. you are the bomb! thanks so much!
that time bug was killing me.
cheers!

personal avatar

hubs, on March 1, 2007

Unfortunately I am getting an error on the top of my page that reads:

Warning: array_slice() [function.array-slice]: The first argument should
be an array in
/home/.jerrie/hubs/artifacting.com/blog/wp-content/themes/k2/stream.php on
line 115

Warning: Invalid argument supplied for foreach() in
/home/.jerrie/hubs/artifacting.com/blog/wp-content/themes/k2/stream.php on
line 117

This is the section of the code giving me problems:

$details = array(‘title’,’link’);
$list = array();

foreach ( life::defaultStreams() as $name => $feed ) {
$rss = @fetch_rss( $feed );
$items = $rss->items = array_slice( $rss->items, 0 ); **THIS IS LINE 115**

foreach ($items as $item ) {
$date = strtotime( substr( $item[‘pubdate’], 0, 25 ) );
$date += 00*10;
$list[ $date ][ “name” ] = $name;

foreach ($details as $detail) {
$list[$date][‘title’] = $item[‘title’];
$list[$date][‘link’] = $item[‘link’];
}
}
}

Do you have any idea what might be causing this?
Again thanks for all your help. I know you owe me no favors, so i
sincerely do appreciate it!

personal avatar

Gunnar Hafdal, on March 1, 2007

No problem, I’m glad that I can be of any help :)

personal avatar

tozé, on March 1, 2007

i’m sorry to pester you chris (or anyone into php, anyway), but i figure the reason the plugin isn’t working for me is that the server that hosts me is still on php4. so is there any gracious soul who’d convert this to php4? i’d be very grateful :)

personal avatar

hubs, on March 1, 2007

what plugin are you guys using that allows for php in your content and pages?

personal avatar

Alec, on March 1, 2007

My lifestream page is empty. No errors, just a blank page. Install is setup correctly with lifestream as the page template. Any clue where to start here?

personal avatar

Phil Bowell, on March 1, 2007

Can somebody please post a fixed version of this that works with PHP 4? I have tried both these versions, followed the fixes I found in the comments and it won’t work. Please? I want this to work but I can’t get it to! You can see my pleas for help above and on Binary Bonsai and other sites that have it but no one will help me. I would really appreciate it if someone could either help me or post a fixed version of the files!

personal avatar

laihiu, on March 1, 2007

thanks for the great plugin, Chris!

to Alec above who got an empty page - this happened to me too, but it is solved after i made a feedburner feed for twitter (like what Chris mentioned in his post above).

personal avatar

Gary, on March 1, 2007

This plugin is great.. Never seen something like this before..

However…

I seem to be having a problem no one else has mentioned. The lifestream is working okay. I was having time issues so I commented out the timezone line in stream.php, but now (and I don’t know if it’s related) I have no days showing up as little headings. I just get one long unbroken list of stuff. I’ve checked the source code the rendered page and the days are there, they are behind the table or something. Can anyone help?

personal avatar

Adam, on March 1, 2007

Chris thanks for the great plugin, but as usual I’m having a few problems.

The LifeStream installed and is working but some feeds are not showing up; namely Twitter and Del.icio.us. I’ve run them both through FeedBurner just to be on the safe side and according to the stats there is a WordPress bot subscribed but nothing appears in the list.
I can only presume that it is timing out or something, is there a way to over come this?

Cheers.

personal avatar

Robert Andrews, on March 1, 2007

Nice. I do a similar thing with my site. Actually, with my Stalker Feed, rather than on the web page per se yet - stupid final privacy concern. Have been considering uniting on the page, though; maybe I’ll implement this or maybe I’ll feed everything into FeedWordpress to keep it on-site.

personal avatar

Paul, on March 1, 2007

Thanks for the inspiration… and implementation :)