Create an RSS Feed from my Facebook Wall using PHP

I wanted to create an RSS Feed from my Facebook Wall and display it on my website.

I wanted to use PHP's simplexml_load_file() function to do this but ran into some issues with Facebook blocking the function.

A work around was modifying the user_agent so that Facebook sees my PHP request as coming from a standard browser rather than from PHP; and instead of using simplexml_load_file(), I used file_get_contents() in conjunction with simple_xml_load_string().

Instructions:

  1. Login to Facebook

  2. Go to your Wall

  3. On the first column of the page look for "Subscribe via RSS" and click on that.

  4. By doing so you will get a URL, that looks like: feed://www.facebook.com/feeds/page.php?id=[YOURFACEBOOKID]&format=rss20

  5. For the script to work, change feed:// to http://

  6. Copy and paste the script below and be sure to change the value of $feedURL to your feed URL that you created using steps 1-5 above.



  7. The code above will list entries on your wall in an un-ordered list. It will pull the link, title, and post date.

  8. If you want to pull more values, simple put print_r($entry); break; inside the foreach loop. This will run the loop once and break out displaying a list of elements inside of the entry object. Put this snippet immediately at the top of the foreach loop so its the first thing that runs.

Keywords: create rss from facebook wall using php, simplexml object


Submit a Comment