
Where do I start?
I recently had a need to get involved with the Facebook API and SDK. The task was to allow users to register with a website and log in using just their Facebook credentials. In other words, no on-site sign up.
There is so much information online on this topic, whilst researching, I ended up with about 20 different tabs open, admitedly most of the sites provided the same or very similar infomation however it took me a little while to get my head around the process. Not only that but some of the information I was reading was out of date and used the old Facebook API.
During my research I thought…
‘hmmm, I wonder if I’m reinventing the wheel here, surely someone has provided a download of the finished process rather than just code snippets’.
Well I was wrong. Yes, there are code examples online however none provided the whole process nor used the recommended code as defined by Facebook; none that I could find anyway.
Once I’d completed the Facebook log in process I decided to put the solution online to help others. I’m not going to go over how it all works, that info is well covered online, I am simply providing a finished ‘toolkit’. If you are a web developer then the code should be a breeze to understand. Of course you need a Facebook App ID and App Secret so you’ll need to set up Facebook App.
Getting a bit technical…
The solution uses the latest (March 2017) Facebook PHP SDK v5 and Javascript SDK v2.8 Graph API. The initial log in is handled by the Javascript SDK for the optimum user experience, the access token is shared between the Javascript SDK and the PHP SDK and the short lived access token is replaced with a long lived version. There is a keep alive process on expiration of the local session which seamlessly passes the user back through the login flow, if the long lived token has also expired then the user must physically log back in via Facebook.
The code uses jQuery, AJAX, Javascript and PHP.
You can find the download on my Github account.
Download the toolkit from GithubPlease note I do not provide any support.

