Skip to content

Facebook News Feed RSS

What up everyone?

The new Facebook feature of showing all the minor details of everyone on their home page got me thinking. This is exactly the type of info that one might want in something like say…and RSS feed?

So the past few hours I’ve spent coding up a little PHP script that will log in to Facebook for you, get that whole feed thing, and put it in crude, simple RSS 2.0 feed.

It was developed using PHP 5 but I think should also work with 4.3.x so long as the ‘dom’ module, curl and libcurl with SSL are installed. I think most webhosts these days have that.

So the script, just put in your Facebook email and password into the facebook-rss.php script in the correct variables. ($login_email and $login_password). Then just hit that page with an RSS reader and it should then tell your all those details you’d see only in RSS format. Perhaps would made a nice google.com/ig module?
Not sure how useful this will be to anyone but it was fun for me to write it. It is also released under the MIT license so that anyone can view, edit, do whatever they want with the source.

So without further ado: FACEBOOK RECENTLY CLOSED MY ACCOUNT AND THREATENED TO BRING ON THEIR LAWYERS IF I DO NOT REMOVE THE SCRIPT. I HAVE DECIDED MY CURRENT LAWSUIT-FREE LIFESTYLE IS NOT WORTH THE SCRIPT. JUST KIDDING ;)

Be sure to let me know what you think and how terribly coded it is. I ran out of beer. ;)

34 Comments

  1. Wow! I’m really happy to see somebody doing this, I gotta learn PHP someday. I’ll be keeping track of this project for sure, but it would seem that changes facebook has made have thwarted your code! I get the following error, which my php-enlightened friend supposes is due to an unexpected response from facebook:

    Warning: domdocument() expects at least 1 parameter, 0 given in /home/b/bl/blb2311/public_html/facebook-parse.php on line 40

    I checked with phpinfo() to make sure I have –with-dom in the configure, so that’s not it, using php 4.4.1

    Wednesday, September 6, 2006 at 12:02 pm | Permalink
  2. nemik wrote:

    That sucks to hear. I’m trying it now again and it is working fine.

    What I’m running:
    PHP 5.1.2
    Ubuntu Linux OS
    libxml Version 2.6.24
    libxml active

    I was kind of expecting some glitches but the code is all there and there are many other ways to parse HTML than just using PHP’s DOM. Although I do find that method to be the easiest.

    Wednesday, September 6, 2006 at 1:08 pm | Permalink
  3. TechAddress wrote:

    Mark Zuckerberg: Founder of Facebook Responds, please read additional details at:
    http://techaddress.wordpress.com/2006/09/06/mark-zuckerberg-founder-of-facebook-responds/

    Wednesday, September 6, 2006 at 6:45 pm | Permalink
  4. Goob wrote:

    Nice little hack you’ve put together there! Now I can check out what my friends are doing without even loading Facebook in my browser. How convenient. =)

    http://www.facebooktalk.com

    Thursday, September 7, 2006 at 2:54 am | Permalink
  5. Matt Havener wrote:

    I had a bit of trouble but figured it out:

    I added those two lines before the final curl_exec because my host didn’t have the SSL CA certs.

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $raw_data = curl_exec($ch);

    (This was done using dreamhost with PHP5 enabled)

    Tuesday, September 12, 2006 at 1:32 pm | Permalink
  6. Paul wrote:

    I downloaded your code awhile ago and had some problems getting it to work on my webserver. If you wouldnt mind helping me out I would appreciate it.

    Wednesday, September 20, 2006 at 6:37 am | Permalink
  7. nemik wrote:

    Paul, what was the problem?

    Wednesday, September 20, 2006 at 9:56 am | Permalink
  8. Goob wrote:

    What was Facebook’s objections to the script you wrote? It sucks they made you take it down.

    Saturday, November 4, 2006 at 5:20 pm | Permalink
  9. Edgeman wrote:

    The date code is a bit flawed. At least on my server. And apparently Safari is so crap that if it has an date in 1969 it doesn’t display anything at all.
    Anyways, I shouldn’t rant about how I hate Safari.
    $pubdate = date(DATE_RFC822, strtotime($time.date(‘F j Y’)));
    I turned into:
    $pubdate = date(DATE_RFC822, strtotime($time));
    And now dates show up properly.

    Also I set the guid to the $pubdate, because I believe the rss specifices that guid is supposed to be unique? (Usually it’s the permalink to the article, which would be unique). I don’t know if that causes problems (not having a unique guid) but I changed it in mine anyways.

    Tuesday, November 28, 2006 at 9:37 pm | Permalink
  10. nemik wrote:

    Edgeman, thanks! I saw in a tutorial on RSS 2.0 that a similar ‘F j Y’ format was used for date and since it is so generic I decided not to use it as th guid.

    Now something as specific as time() makes a lot of sense for a guid. Thanks again for that tip.

    As for Safari, I’m not too fond of it either though I don’t use a mac; FF all the way for me.

    Friday, December 1, 2006 at 6:42 pm | Permalink
  11. Zaimor wrote:

    Regarding error:

    Warning: domdocument() expects at least 1 parameter, 0 given

    Fixed by changing “$dom = new DomDocument” to:

    “$dom = new DomDocument(”)”

    You need to specify the xml version number.

    Tuesday, December 19, 2006 at 2:53 am | Permalink
  12. Zaimor wrote:

    That was supposed to say between the ‘s:
    (lessthan)?xml version=”1.0″ encoding=”utf-8″?(greaterthan)(lessthan)root /(greaterthan)

    Tuesday, December 19, 2006 at 8:49 am | Permalink
  13. Tina wrote:

    Is there anyway to hack on to someone’s account. I would love to do this to a prospective boyfriend.

    Thursday, January 11, 2007 at 7:50 pm | Permalink
  14. Ashley Johnston wrote:

    I happen not to have a webserver. Is there still no way for non-backenders to get a Facebook rss News Feed? Anyone want to set one up for me?

    Thursday, February 22, 2007 at 1:53 pm | Permalink
  15. nemik wrote:

    Ashley,

    No.

    Saturday, February 24, 2007 at 7:39 pm | Permalink
  16. Mark Barnes wrote:

    This seems to be broken with the Facebook facelift. Will you be able to fix it?

    Friday, April 13, 2007 at 8:49 am | Permalink
  17. nemik wrote:

    Mark,

    Seeing as how I’m b& from the site I don’t think so. Though if you know a little about the code and read it is fairly straight-forward and should be pretty easy to modify.

    Though Facebook seems to just want to control its own site as much as possible. It is not very much about innovation or anything like that and it seems most attempts to add some 3rd party features to the site are only met with threats. So it is not really a site I would really even bother trying to improve or add features to.

    Friday, April 13, 2007 at 11:50 am | Permalink
  18. Mark Barnes wrote:

    Sorry you’re disillusioned by Facebook, but I understand. My problem is that I code in ASP not PHP, so I don’t understand all the XML parsing that you’re doing. But I guess I can work that out. I also thought it might be worth parsing from the Mobile pages, rather than the normal pages as the (X)HTML is much simpler there – and the code gets updated much less often.

    Can I ask whether you got banned because you wrote the script, because you made it available, or for another reason? I don’t want to get banned too!

    Monday, April 16, 2007 at 7:28 am | Permalink
  19. nemik wrote:

    Mark,

    They must have introduced Mobile Pages recently because it was not available when I checked.
    Another thing to look for is if perhaps they are using AJAX to update some feeds on the site instead of inserting it to the HTML source directly. If so, do an Ethereal (well Wireshark now) trace while loading the page and you may get to their site that outputs the XML for the feed, and with XML it doesn’t get much easier as far as parsing is concerned.

    As for the ban, I posted the email I got from them in another post on this blog you can check out. I imagine it was because I made it publicly available. Though the script is kind of dumb and logs itself in each time. This could be avoided by just re-using the cookie that they send down for when you’re logged in and then passing that in to cURL so as to not have to log in and perhaps alert them that something is going on.

    Anyway, cheers and all the best.

    Monday, April 16, 2007 at 8:02 am | Permalink
  20. Csaba wrote:

    Hello, just wonder, how are now the things with facebook are going -related to their new policy.

    I hope, many rss feature will come up :)

    Csaba

    Sunday, June 3, 2007 at 6:58 am | Permalink
  21. farhad wrote:

    after several attempts now, I could not get the script to work. Can someone please post a link to a working file so we can view the source? I am in php 4.4.7.

    Friday, June 22, 2007 at 10:24 pm | Permalink
  22. Bisqit wrote:

    hey, i was wondering if there was a way to get this feed to be of my own photo album updates? Or do you know how to set that up?

    I am barely familiar with scripting. so idiot-proof instructions would be awesome!

    Tuesday, July 3, 2007 at 4:49 pm | Permalink
  23. Lamp wrote:

    Pretty awesome script. Aside from the security issues, it would be nice if a *trusting* server hosted one script, and used HTTP_GET_VARS for user e-mail and password. =D

    Friday, August 3, 2007 at 11:35 am | Permalink
  24. Lily wrote:

    You need to add this line, did not work for me otherwise:

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    Friday, August 24, 2007 at 4:27 pm | Permalink
  25. Tim Yang wrote:

    Hi! I love your news feed grabber! It’s what I’m looking for!

    But I’m having an error that I can’t understand. I get this message when I run facebook-rss.php.

    DOMXPath::evaluate() [function.DOMXPath-evaluate]: Invalid or inclomplete context in /home/.scipio/mywebsite/mywebsite.com/facebook-rss/facebook-parse.php on line 96

    Would you know how I might resolve this? Is it a

    Wednesday, September 19, 2007 at 8:57 am | Permalink
  26. Arati wrote:

    Hi,

    I have download the facebook-rss.zip and replaced the login and password ,

    I got an error:
    Warning: domdocument() expects at least 1 parameter, 0 given in /var/www/httpdocs/facebook/facebook-parse.php on line 40

    I have changed the code for line 40 as Zaimor said
    from :

    $dom = new DomDocument

    to:

    $dom = new DomDocument(1.0)

    I have give xml version 1.0

    then another error is display :

    Warning: domdocument(): Start tag expected, ‘

    Friday, September 21, 2007 at 3:29 am | Permalink
  27. Jason wrote:

    I’m getting the exact same thing as Ben mentioned in the #2 comment above :/

    Tuesday, September 25, 2007 at 12:37 pm | Permalink
  28. Paul Christy wrote:

    Ok I was getting errors in PHP 4.X.X with the DOMdocument(). Here is the fix…it’s on line 18 of the parse.php document.

    $dom = new DomDocument(”);

    Wednesday, November 7, 2007 at 10:37 am | Permalink
  29. Anders wrote:

    Great script! I am getting an error, any idea what it is? I am using php 5

    Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /var/www/atbl.dk/public_html/fbrss/facebook-rss.php on line 63

    Wednesday, January 9, 2008 at 6:52 am | Permalink
  30. Alvin wrote:

    I’m also getting the same error as Tim Yang:

    DOMXPath::evaluate() [function.DOMXPath-evaluate]: Invalid or inclomplete context in /home/.scipio/mywebsite/mywebsite.com/facebook-rss/facebook-parse.php on line 96

    How do I solve this?

    Thanks.

    Friday, April 11, 2008 at 3:38 pm | Permalink
  31. Alex wrote:

    Can you get this to work with new Facebook?

    Monday, January 5, 2009 at 10:36 pm | Permalink
  32. Michael wrote:

    I’ve updated this script to work with the new Facebook: Get it here.

    Wednesday, February 18, 2009 at 5:31 pm | Permalink
  33. nemik wrote:

    very nice!

    Saturday, February 28, 2009 at 12:57 pm | Permalink
  34. Debbie McGrew wrote:

    I do not get new feeds. I can only see the past 15 – 22 hours at the time I loge on. I would like to see what is posted at the time I loge on. can some one help me!!!!

    Monday, October 3, 2011 at 1:26 pm | Permalink

2 Trackbacks/Pingbacks

  1. theory.isthereason » Fearmongering Facebook’s News Feed… on Thursday, September 7, 2006 at 1:43 am

    [...] Update 3: Nemik rawks. Why? Because he just wrote script last night thattransforms the Facebook News Feed into RSS. Grab the source, customize it then stay tuned to your Facebook network via RSS newsreader! Readership (45) | [...]

  2. Facebook News Feed RSS | Michael Tyson on Wednesday, February 18, 2009 at 5:29 pm

    [...] ‘Nemik’ has created such a thing and kindly made it available. It was a bit elderly, and didn’t work with the new Facebook, so I jazzed it up a bit. [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*