In our current implementation of the "My Friends" page in Our 1st FB App (PHP SDK), we have set a max limit of 25 friend objects to be returned when reading the "me/friends" connection via the Graph API. While this improves the application performance, we still need to find a way to access the "next page" of friend objects in the "me/friends" connection. This is where the concept of Paging comes in.

Paging through the objects in the Facebook's social graph can be accomplished by using the "offset" parameter and "limit" parameter at the same time.

As an example, we will enhance the existing "My Friends" page with the paging feature shown below.


Implementing Paging in "My Friends" page

First of all, to implement the paging feature, we need a way to keep track of the "page number" of the data being processed (in our case, each page of data consists of 25 friend objects).

One of the easiest way to implement this is to pass the "page number" as an URL parameter. For example, to display the 5th page of data in the friends object, we can use the following URL:

Based on the "page" parameter, we need to have the following processing in the enhanced "My Friends" page: