thedp
thedp

Reputation: 8508

Using Facebook API paging?

I'm new to Facebook API and I would like to get information on the friends the logged user has. At first I had default privileges configured so all I got was just the names.
Once I've requested for additional privileges, it gave me a 'paging' object... But I have no idea of what am I suppose to do with it.
For some reason I wasn't able to find anything useful with Google, so here I am.

Here is what I have so far:

index.html

<script src="http://connect.facebook.net/en_US/all.js"></script>
<script src="script.js"></script>
<script language="javascript" type="text/javascript">
        FB.init({
            appId: '118236041675713',
            status: true,
            cookie: true,
            xfbml: true
        });  
</script>
<fb:login-button perms="email,user_birthday" autologoutlink="true">

script.js

$(document).ready(function() {
        FB.login(function(response) {
           if (response.authResponse) {
              FB.api("/me/friends", {fields: 'name,id,birthday'}, function(res) {
                 console.log(res);
              });
           }
        });
});

SOLUTION: Additional info can be received from the next/previous properties. Important note: For some reason the jQuery $.get does work. So I had to use $.ajax:

$(document).ready(function() {
            FB.login(function(response) {
               if (response.authResponse) {
                  FB.api("/me/friends", {fields: 'name,id,birthday'}, function(res) {
                     var next = res.pages.next;
                     $.ajax({
                url: next,
                success: function(data) { alert(data) },
                dataType: 'html'
              });
               }
            });
    });

Upvotes: 0

Views: 2997

Answers (1)

Jason Reeves
Jason Reeves

Reputation: 1716

The paging object will have 2 properties.

paging.next - this contains the url to the graph call that will return the next page of results

paging.previous - same but for previous page in results

Upvotes: 1

Related Questions