postHowto: Facebook status on your blog - Technology - 19th August

Note: there are many different ways to to this. This is my personal approach.

Facebook provides RSS feeds for lots of things. One of these is the “Mini-feed” on your own profile. This can then further be filtered by “Status Stories” - this just being your own status updates in an RSS feed. Sounds promising…

Grab the URL for the RSS feed of this page. Now, we can’t just fopen() this URL in PHP as facebook are sneaky. They verify that the User-Agent is an actual browser or feed-reader. My approach was to use wget and it’s --user-agent parameter to pretend to be Internet Explorer. Dump the resulting XML somewhere and then parse out the inner HTML of the first <title> element. This is your current status. Easy.


Warning: Invalid argument supplied for foreach() in /usr/local/vhosts/ollyjackson.co.uk/wordpress_svn/trunk/wp-content/themes/cyber-junky/theloop.php on line 23
 

One comment on “Howto: Facebook status on your blog” / Add your own

  1. I did it a wee bit different using cURL :


    $ch = curl_init();
    $fb_profile_url = "http://www.facebook.com/feeds/status.php?id=XXXXXXXXX&viewer=XXXXXXXXX&key=XXXXXXXXXX&format=rss20";
    curl_setopt($ch, CURLOPT_URL, $as_profile_url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_TIMEOUT, $feedtimeout);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.1) Gecko/20061223 Firefox/2.0.0.1");

    $fresh_rdf = curl_exec($ch);

    I cache it to a file and only recheck when the cache files is X old. They sure hide the RSS feed for your status updates.

Add a new comment

  • You can use these tags in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
  • Comments are gravatar enabled.