2

I am wondering if this is a Facebook bug or something that I am doing wrong. Anyways, I am developing a server application that talks to my own simple Facebook app via Graph API calls. For development purposes, the only users of the Facebook app are a few Test Users that I have defined. In this scenario, I have one test user "Lisa Mills" and I want to return a list of her friends. Her only friend is "John Smith". I use the Graph API HTTPS call for retreiving her list of friends, like so (links probably won't work anymore, but they are posted here for illustrative purposes):

https://graph.facebook.com/100004330990794/friends?access_token=AAAGGG3niQkQBAPne8jGOcfZAUZCiqbgDMAPV0QlA5GMGorFdEZCOBAX3daZAOkcWmenyfFwYzuBCxrE2gEOXaZAa7tJptZBE826vvHdw7JtCZB0If9mJ041

The resulting data:

{
   "data": [
      {
         "name": "John Smith",
         "id": "100004375356845"
      }
   ],
   "paging": {
      "next": "https://graph.facebook.com/100004330990794/friends?access_token=AAAGGG3niQkQBAPne8jGOcfZAUZCiqbgDMAPV0QlA5GMGorFdEZCOBAX3daZAOkcWmenyfFwYzuBCxrE2gEOXaZAa7tJptZBE826vvHdw7JtCZB0If9mJ041&limit=5000&offset=5000&__after_id=100004375356845"
   }
}

What is puzzling is why the JSON response contains a "next page" value because Lisa is not going to have any other friends to return. Anyways, if I go to the URI specified in the JSON, I receive this response:

{
   "data": [
   ],
   "paging": {
      "previous": "https://graph.facebook.com/100004330990794/friends?limit=5000&offset=0&access_token=AAAGGG3niQkQBAPne8jGOcfZAUZCiqbgDMAPV0QlA5GMGorFdEZCOBAX3daZAOkcWmenyfFwYzuBCxrE2gEOXaZAa7tJptZBE826vvHdw7JtCZB0If9mJ041"
   }
}

Of course...no data is returned. I would naturally presume that this "next page" should only have additional data if Lisa had over 5000 friends. Is this a bug in Facebook's Graph API, or is this a normal situation that my server application needs to handle without error?

ecbrodie
  • 11,246
  • 21
  • 71
  • 120

1 Answers1

2

I would naturally presume that this "next page" should only have additional data if Lisa had over 5000 friends. Is this a bug in Facebook's Graph API, or is this a normal situation that my server application needs to handle without error?

In a recent developer blog entry, Facebook said they had “fixed” this for some parts of the API:

“For selected edges, we’ve introduced cursor-based offset paging. This improvement definitively indicates when you've reached the end or beginning of a data set. We'll no longer show the ‘previous’ or 'next' paging links when there's no new data. This translates to faster request processing times, saving you one round-trip every time you page through an entire collection. We're working on adding support for more edges.”

Looks like the /user/friends connection is not one of those “selected edges” yet …

CBroe
  • 91,630
  • 14
  • 92
  • 150