Facebook News Feed RSS
September 6th, 2006
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. ![]()
September 6th, 2006 at 12:02 pm
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
September 6th, 2006 at 1:08 pm
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.
September 6th, 2006 at 6:45 pm
Mark Zuckerberg: Founder of Facebook Responds, please read additional details at:
http://techaddress.wordpress.com/2006/09/06/mark-zuckerberg-founder-of-facebook-responds/
September 7th, 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) | [...]
September 7th, 2006 at 2:54 am
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
September 12th, 2006 at 1:32 pm
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)
September 20th, 2006 at 6:37 am
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.
September 20th, 2006 at 9:56 am
Paul, what was the problem?
November 4th, 2006 at 5:20 pm
What was Facebook’s objections to the script you wrote? It sucks they made you take it down.
November 28th, 2006 at 9:37 pm
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.
December 1st, 2006 at 6:42 pm
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.
December 19th, 2006 at 2:53 am
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.
December 19th, 2006 at 8:49 am
That was supposed to say between the ’s:
(lessthan)?xml version=”1.0″ encoding=”utf-8″?(greaterthan)(lessthan)root /(greaterthan)
January 11th, 2007 at 7:50 pm
Is there anyway to hack on to someone’s account. I would love to do this to a prospective boyfriend.
February 22nd, 2007 at 1:53 pm
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?
February 24th, 2007 at 7:39 pm
Ashley,
No.
April 13th, 2007 at 8:49 am
This seems to be broken with the Facebook facelift. Will you be able to fix it?
April 13th, 2007 at 11:50 am
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.
April 16th, 2007 at 7:28 am
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!
April 16th, 2007 at 8:02 am
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.
June 3rd, 2007 at 6:58 am
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
June 22nd, 2007 at 10:24 pm
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.
July 3rd, 2007 at 4:49 pm
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!
August 3rd, 2007 at 11:35 am
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
August 24th, 2007 at 4:27 pm
You need to add this line, did not work for me otherwise:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
September 19th, 2007 at 8:57 am
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
September 21st, 2007 at 3:29 am
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, ‘
September 25th, 2007 at 12:37 pm
I’m getting the exact same thing as Ben mentioned in the #2 comment above :/
November 7th, 2007 at 10:37 am
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(”);
January 9th, 2008 at 6:52 am
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
April 11th, 2008 at 3:38 pm
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.