Now, back to the code in our 1st Facebook application.

I presume you have successfully deployed our 1st Facebook application and tested it. So, you have already used the old Rest API client library (which is also known as the "Old PHP client library).

 

Using the Old Rest API Client Library

Instantiating the "Facebook client" Object

Forcing Application User to Logon to their Facebook Account.

As we are developing Facebook application, we should have a way to ensure that the user has been logon to their facebook account. Unless the user has logon to their account, there is no way our app to access Facebook's feature. This is done by the following single line of code:

In fact, the above code will do the following for us:

Notice that this "require_login" page is not a mandatory action for your facebook application page. For example, we can present to the user a welcome page, describing what our application will do (e.g. describing our game). Only when the user clicks the "Start" button, the user will be redirect to another PHP page (which holds the actual game component) which has the "require_login" call. (We want to enforce the user to login to their facebook account as we want keep the "Highest Scores".)

 

Getting the Friend List of the User

Another example usage of the Old Rest API client library in our code is getting the friend list of the user. This is done by the following code:

Notice that the friend list will be returned as an array.

 

Frankly speaking, I haven't found any comprehensive documents on this client library, explaining every API / feature of it. To know more about this client library, you may need to refer to the source file facebook.php and facebookapi_php5_restlib.php within the library.

While the Old Rest client library is developed on top of the Old REST API, we can also refer to the official documentation of the Old REST API.

 

Leave me a note if you know where we can find good references for this client library.