Chuck Le Butt Chuck Le Butt - 1 month ago 6
PHP Question

Displaying a Facebook newsfeed/timeline on a website

I have a client who wants their company's Facebook newsfeed/timeline to be displayed on their website. It's not a personal timeline/newsfeed, but an organisation's.

Everything I've read seems a few years old, but the upshot appears to be: Facebook wants to keep all its data on its own servers -- they don't want people exporting it, and people have been banned for trying. (As I say, this information was several years old.)

The closest current thing I've found is the Activity Feed Plugin, but that only registers other user's interactions with the site or a FB app.

Has anyone had any success exporting their public updates to an external website, or do I have to tell my client that it can't be done?

Thanks for any help!

Answer

AFAIK, it is possible, in a way. The simplest solution, but not best for your situation could be the Like Box plugin:

The Like Box enables users to:

See how many users already like this Page, and which of their friends like it too
Read recent posts from the Page
Like the Page with one click, without needing to visit the Page

Better solution: use their Graph API, however you can only read the data(as JSON), not have the stream exactly replicated on your client's website, don't expect to be able to apply the styles that facebook uses(i.e you won't be able to scrape it), you'll have to either replicate it, or create your own styles.

Now if the page is public and can be read by all, as in there are no privacy rules, then you can simply call the url with any valid access_token(can be app access_token also):

https://graph.facebook.com/<clientpagename_OR_id>/feed

or

https://graph.facebook.com/<clientpagename_OR_id>/posts

depending on what exactly you need, try the graph api explorer to check that(and also see the kind of data being returned). When there are lots of posts, there will be pagination urls, which you'll be able to notice in the explorer too.

Incase the page is not public, you'll need an access_token with the read_stream permission, hence you'll need to create a facebook app, of type website. Then get your client's page's admin to authorize the app, with read_stream permission. After that you can call the urls with the access_token that you receive after authentication and can continue reading the stream.

https://graph.facebook.com/<clientpagename_OR_id>/posts?access_token=thetoken

In this case use the PHP SDK, to simplify authentication and calling the graph api.

Important Links: Authentication Guide , Real-time-updates.

Good luck.

Edit: you do need an access token to access the feed or posts connections, but you donot necessarily need an access token to read the page object itself, as given in this documentation.
Note from the doc:

For connections that require an access token, you can use any valid access token if the page is public and not restricted. Connections on restricted pages require a user access token and are only visible to users who meet the restriction criteria (e.g. age) set on the page.

Comments