Gray's Matter
Justice Gray - North America's favorite metrosexual software consultant

I Wish These People Updated More Than Once a Year

Facebook RSS Feeds - How to write your own

As you can see from the above picture, I have been busy coding something that will change the lives of EVERYONE IT TOUCHES.  We'll get to that, but first I want to talk a little bit about the Facebook phenomenon.

For those of you who don't know what Facebook is, my wife has written an excellent primer on the subject, and so has Mack Male.  It seems to have taken off in a big way thanks to its slick UI and social networking features.  For the time being, Facebook is the place to be for geeks and non-geeks alike.  My wife, Mack Male, Steven Rockarts, Ridley Thunder, and Catherine Silzer are only a *few* of the names you can find hanging out on Facebook.    Even Kyle Baley is there, despite being notoriously anti-social to the point of barricading himself in the Bahamas so he can "just be away from all those filthy plebes".   Today the Facebook community recieved another newbie in the form of D'Arcy Lussier, who claimed that he was just signing up because "all of my non-geek friends are doing it".  *PLEASE*.   I think we all know why D'Arcy all of a sudden felt the driving need to be on Facebook:

John Bristowe is in Facebook - D'Arcy Lussier is orgasmic

Some things never change.  Can a restraining order be far away?

Anyway, I like Facebook as it allows me to keep in touch with some of my friends who are less technical, and reunite with some old friends who I never thought I'd see or hear from again.  If the price of this is to refuse the same message of "Can you confirm you and Steve Rockarts hooked up?" 25 times, then so be it.   However, there are two things that I dislike about Facebook:

a) I have to login every time someone takes an action towards me
b) The "news feed" on their main page that updates you on your friend's activities, messages, wall posts is not exposed as an RSS feed, so you constantly have to login to get that as well.

I, my friends, have solved this problem by writing my own Facebook RSS feed.    So can you - all you need is the .NET Framework 2.0 and some familiarity with C# !!   I need to say that Nemik's efforts in PHP were a huge help in my figuring out what needed to be done here and he deserves a large amount of credit.   Also thanks to David Woods and Steven Rockarts for helping piece together a nagging issue and to Kyle Baley for being a huge show-off!  

The files are attached here, including a small readme with what you need to do to get this going.  Please note you will need to change the E-mail and password from "YOUR_EMAIL" and "YOUR_PASSWORD" if you want this to work.  If there are any *other* issues with the code, please feel free to contact me either via E-mail or preferably via blog comment on this post and let me know!  

At last I can get my news updates without logging in!  Although when you have stuff like this in your updates:

"Mack Male is looking for random play, ladies!"
"Mack Male is *still* looking for random play, ladies!"
"Mack Male is getting ANGRY, ladies"
"D'Arcy is wondering why John Bristowe needs to involve the police"


maybe it's better to just not login to Facebook at all?

Saturday, April 07, 2007 #

4/6/2007 7:59:53 PM (Mountain Daylight Time, UTC-06:00)
Awesome Justice! That's funny, I did pretty much the same thing! I wrote an app that lets me update my Facebook status without having to go to the website and login, and I wanted it to show everyone else's status too.

Anyway, nicely done. Great minds think alike!
4/6/2007 8:05:30 PM (Mountain Daylight Time, UTC-06:00)
My suggestion for the code would be to use WebClient instead of the nasty HttpWebRequest and HttpWebResponse objects! Only extra step is to make a new class (WebClientEx) that inherits from WebClient and adds a CookieContainer.
4/7/2007 8:52:36 AM (Mountain Daylight Time, UTC-06:00)
Thanks for the suggestion Mack! I'm not all that big on the WebResponse/WebRequest objects either, and your suggestion certainly sounds like it would be a bit cleaner.

I might have to talk to you about WebClient and how its doing its POSTS; I figure WebClient saves its cookies internally (haven't checked it w/ Reflector to be sure) so I'm not worried about a CookieContainer. But when I do the POST with a WebClient, I end up just hitting the login screen again. (??)
4/7/2007 2:10:51 PM (Mountain Daylight Time, UTC-06:00)
Yeah, it doesn't save cookies. That's why I had to add the CookieContainer (and override a few methods). I'll send you the class via email.
4/8/2007 1:00:17 AM (Mountain Daylight Time, UTC-06:00)
I can't believe you referenced Steve 3 times in your blog!... but thanks for throwing me in there :P
4/8/2007 2:11:49 AM (Mountain Daylight Time, UTC-06:00)
Catherine, I totally owed Steve for helping break past a *huge* stumbling point. I would've mentioned him every paragraph if I didn't know he'd get a little too excited! ;)
4/9/2007 8:42:39 PM (Mountain Daylight Time, UTC-06:00)
Wow, lotta good that RSS feed is doing for you .. I've been waiting a whole 20 mins for you to accept my friend request .... maybe it's a timezone thing and you'll catch up in 3 hours.

4/9/2007 8:48:01 PM (Mountain Daylight Time, UTC-06:00)
RSS Feeds don't work when I'm not at home, stalker man!! ;) You're in now.
4/10/2007 8:37:47 AM (Mountain Daylight Time, UTC-06:00)
Hey I'm no stalker .... just getting caught up in the FaceBook addiction.

You'd think that Donald would sign up ... what with all the friends he has and stuff.
4/10/2007 11:54:15 AM (Mountain Daylight Time, UTC-06:00)
It *must* be the fact that Donald has too many friends that he is not on Facebook. What skeletons in his closet is he hiding!?!
4/10/2007 2:14:28 PM (Mountain Daylight Time, UTC-06:00)
Why must your comment threads always turn to discussions about me? If I'm all you guys talk about I'm surprised it's me who can't get a damn date.
4/10/2007 2:15:50 PM (Mountain Daylight Time, UTC-06:00)
Buddy, I'm thinking that if you want dates, Facebook is the place!! Tons of women on there looking for hookups, I am sure.
4/11/2007 7:21:01 AM (Mountain Daylight Time, UTC-06:00)
"just be away from all those filthy plebes"

Someday, I'll explain how ironic that statement is.

P.S. Don't tell anyone what I helped you with. It's bad enough people think I'm a Livelink expert at my current company.
4/11/2007 7:48:58 AM (Mountain Daylight Time, UTC-06:00)
Don't worry, Kyle - your hairstyling tips will remain a closely guarded secret between you and I.

Or did I say too much?

4/28/2007 6:04:07 AM (Mountain Daylight Time, UTC-06:00)
At the moment every time I refresh the feed I get duplicates appearing.

Could you possibly save a cookie that stores the last item downloaded, and then only include items after that in the feed?

Thanks,

Tom
4/28/2007 7:00:36 AM (Mountain Daylight Time, UTC-06:00)
(All less than replaced with $$, greater than with %%.)

I fixed it by using a more sensible GUID string:

rssBuilder.AppendFormat("$$guid isPermaLink=\"false\"%%$$![CDATA[{0}]]%%$$/guid%%", item.Content );

I also gave items more sensible titles with:

newFacebookItem.Title = Regex.Replace( htmlSegment, "$$[^%%]+?%%", "" );

I'm sure you can figure out where those two changes are.

Tom
4/29/2007 7:00:03 PM (Mountain Daylight Time, UTC-06:00)
Very cool, works great.
I was researching facebook rss feeds because i want to create a feed for my digital picture frame for all my friends new pictures. I tried to tweak your code a bit to start on the photos.php page, but that's only album covers. then i tried to parse only pictures in the news feed, that wasnt good because not every new picture gets posted there. so i decided to start directly into each of my select friends profile id=whatever, and then parse their mini-feed for new pictures. the two problems are 1) when i try to use id=? instead of home.php as the start page it doesnt goto the id instead it goes to the newsfeed. once im logged in, can i redirect the stream to a new url? 2nd, and i guess everyone has this problem. the photos arent permalinked so does that mean my picture frame wont even show them properly and this is a huge waste of time? Any help would be awesome!
Alex
5/2/2007 4:58:42 AM (Mountain Daylight Time, UTC-06:00)
I've fixed the broken photo links problem. I've also got proper RSS pubDate stamps working, so the times appear right in the RSS reader. I'm going to email my updated files to the author and hopefully he'll post them somewhere accessible.

Tom
8/3/2007 9:02:45 PM (Mountain Daylight Time, UTC-06:00)
Hi,
great idea!

just wondering if you can help me, I'm doing a port of this to delphi7, so have to do everything the old fashioned way!
have got it working fine apart from... however I tinker with the delphi implementation of regex it only gives me every other news story as it picks up the "feed_story_wrapper clearfix" either end of the statement, so then skips a story because it thinks the next start tag is the end of the previous one.. my question is.. is this a bug in the delphi (pre NET) version of regex I'm using, or does yours do this as well?

Cheers,
James
11/14/2007 9:36:29 AM (Mountain Standard Time, UTC-07:00)
Any addiction is bad for i can tell you that....
3/22/2008 9:39:02 AM (Mountain Daylight Time, UTC-06:00)
Brand Wellbutrin Delivered
3/22/2008 9:45:14 AM (Mountain Daylight Time, UTC-06:00)
Wellbutrin With Online Consultation Online
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):