Displaying a Facebook feed on a website

Displaying posts from a client’s Facebook page on their website provides a way to integrate their Facebook presence with their site. 

It also provides fresh content on the client’s site, without them having to update the site directly. This can be a boon for clients who are more comfortable updating Facebook rather than logging into a content management system.

Facebook has its Graph API for allowing developers to update and retrieve Facebook information, but every Facebook site also has a feed available, either as RSS or ATOM. This feed only provides access to Wall posts, not other posts (such as Follower’s comments).

This article describes how to access a Facebook feed, with particular reference to Processwire.

The Facebook ID

To access the feed you have to know the account’s ID. Depending on how the client’s account is set up this may not be readily apparent. There are a number of ways to find the ID, but one of the easiest is to use a service like http://findmyfacebookid.com/.

The feed

Once you have the account ID (let’s call it 11111111), the feed can be accessed through:

  • https://www.facebook.com/feeds/page.php?format=atom10&id=11111111 (Atom 1.0)


  • https://www.facebook.com/feeds/page.php?format=rss20&id=11111111 (RSS 2.0)

Using the feed

Once you have access to the feed you can parse it to pull out the information you want to display. But there are a few tricks to accessing the feed programmatically (for example using PHP).

Unlike many feeds, the Facebook feed is delivered via a secure connection. If you are using PHP you will need to ensure that it is configured to open secure connections. Make sure the following lines are uncommented in your php.ini,

allow_url_fopen = On

In addition, Facebook will not return a feed unless it knows the user agent. If you put the feed address in your browser you will get a response because your browser sends the user agent as a part of the header. By default the user agent in a PHP request is set to null and Facebook will not send a response. To get around this set the value of user_agent—either in php.ini, or by including the following statement in your code before you attempt to open the feed:

ini_set("user_agent", "php_script");

(The value of user_agent can be set to whatever string you like - here “php_script” is used.)

Manipulating the feed in Processwire

There are two great modules in Processwire that makes the parsing and manipulation of the actual feed a breeze: 

Once you have access to the Facebook feed, the instructions that come with these modules tell you everything you need to know to display the feed how you want.

Published: Sunday, 21 July 2013

Last updated: Saturday, 3 August 2013