Embed activity feed of a public Facebook page without forcing user to login/allow

To get the activity feed of a public Facebook page, like White Collar, follow these steps:

1) Get your App-id and App-secret by choosing an existing app or creating a new one at this url:

https://developers.facebook.com/apps/

2) Get an access token by making a GET request to this url:

https://graph.facebook.com/oauth/access_token?client_id=" + APP_ID + "&client_secret=" + APP_SECRET + "&grant_type=client_credentials

3) Get the page-id of your fan page. To do this, you need the page-name. Go to your fan page on facebook and look at the url. It will have this form:

https://www.facebook.com/{fan-page-name}

Once you have that, make a GET request to this url:

https://graph.facebook.com/{fan-page-name}?access_token={access-token}

It will return a bunch of JSON. You’re looking for the first “id” element. This is your page-id.

4) Get the fan page JSON data with a GET request to this url:

https://graph.facebook.com/" + page-id + "/feed?access_token=" + URLEncoder.encodeUTF8(access-token)

To avoid having exceptions thrown, I had to use URLEncoder.encodeUTF8().
The data you’re looking for is under the “data” element.

I wasn’t able to find anything that would do the JSON parsing of the Facebook feed for me, but I did find this tutorial that will do a lot of the formatting for you to make it look like Facebook.

Hope that helps anyone else trying to do this.

Leave a Comment