How to syndicate posts onto a Facebook Page

I’ve succeeded in syndicating the entries for kliktikfix onto Facebook, where I created a Page for the site. However, the process is a lot more complicated than it is with Twitter, mostly because of the way Facebook uses access authorisation. Also, there is a lot of outdated info to be found when searching for a solution, so I’ve decided to post the solution I’m using, in hopes it is of use to others.
Please note that this code works at this moment. Future API changes might invalidate it, which it did with so many other posts about the subject.
I’m assuming you know your way around PHP and that you have access to a site that runs PHP scripts.

My use case

I’m guessing if you want this, you’re already on Facebook. Next step is to create a Page that you will syndicate to. If you don’t know how to do that, this page will tell you how to go about it.

So far, so good. Now we have to register a new ‘App’, so that we can get the keys to the proverbial kingdom!

Registering a Facebook App

Next, we’ll be creating a PHP script to get a so-called Page Access Token. The whole Access Token thing is explained in the documentation, but in short, here’s what we’ll be doing:

Our flow

Follow these steps to create the script to get the Page Access Token:

Getting the Page Access Token

Now we have our Page Access Token. Remove the PHP script from your server, so that it can’t be called by someone else — we don’t need it anymore, and we don’t want anybody to stumble upon it.

The next step is to create a PHP script that posts to our Page.

Testing posting to the Page

When I had it working, I saw the entries appear. There was only one problem: only I saw the entries! Other users or viewers who were not logged in, didn’t see them! This gave me a few headaches, but in the end the solution was simple.

How to publish your App

It took me quite a bit of time (and some frustrating moments!) to get this working. I hope this posts helps others achieve the same — with less time wasted and less frustration!