The Facebook Connect documentation is pretty limited. In fact, this does not tell you what he is doing, only how to do it. I personally do not use any SDKs. I developed my own framework for my development projects.
Both SDKs, as well as the JavaScript in the tutorial, IMO, are pretty dated.
If you want to stick with one of the FB SDKs, here is my suggestion. Use the JS SDK only if your requests for the Graph API and the like are sent to the PHP server via Ajax. Otherwise, stick with the PHP SDK.
Introduction
Facebook uses oAuth v2. They describe two different flow methods ... Server side and client side. This will be implemented just like any other application that authenticates the oAuth v2 service. They both do the same. The only difference may be that you can use the "code" as request_type to get the authorization code to receive the token in the future.
Authentication
As for FB Connect, then your script should make sure that you have an authentication token or authentication code when authentication is required. If you do not have this, you need to get it. You can use the presence of an authentication code or token as a condition for which the FB button (input or output) is displayed.
Redirect the user to oAuth for authentication. Facebook has its own oAuth implementation related to their conversational API. More on the oAuth dialog box here: http://developers.facebook.com/docs/reference/dialogs/oauth/
You can use an optional status parameter for something like CSRF protection. It saves the value after the process and is sent with a callback as a GET parameter.
Interaction with applications
Basically you are going to write your application in the same way as usual. The differences are as follows:
- Your user database no longer stores the password, but only the FB UID. Also, according to FB Dev ToS, you really cannot store user information. If you want to save user information, you need to get it from the user. You can fill in this information for them with FB information, you just need to send them.
- Your registration method will no longer show a message about opening the form. It will be called when the authenticated user does not have a record in the database.
API interaction
If you went with a code instead of a token, you need to request a token by sending the code. This is done using the Graph API. This part is not documented at all, except in their authentication tutorial. http://developers.facebook.com/docs/authentication/
With your access token, no matter how you use it. Now you can request the Graph API, but you want to. This will return a JSON encoded object.
Conclusion
As for the fast and reliable implementation, the PHP SDK does the job. It handles everything I reviewed here, including CSRF. How to learn this, I still have to find decent documentation. Everything is either old or the writer does not know and leaves other lessons.
Itβs best to go deep into these libraries and find out how it works for you. Conduct trial and error, experiment.
What I found out was writing my own frameworks. I suggest you do the same. You can extend the SDK classes for Facebook if you want. It is truly limited, but it gives you everything you need. I took my most commonly used API calls and posted them. I now have a very fast and simple end result, which is derived from my library.