Facebook Graph API - Setting limit field in get request requires different Oauth key?

296 views Asked by At

Playing around with the java restFB wrapper and I tried requesting all photos from a certain user.

Everything works fine when I use the request https://graph.facebook.com/me/photos, except I am limited to 25 photos. The solution to this is to add the limit field and set it to 0.

So I retried it using the request https://graph.facebook.com/me/photos?limit=0, and this time I am hit with the error "Received Facebook error response of type OAuthException: A user access token is required to request this resource. (code 102, subcode null)" I am wondering if a different Oauth key is needed to get all photos. I am currently getting my key by creating a facebook app.

Thanks!

2

There are 2 answers

2
Niraj Shah On

You should not set a unlimited limit (limit=0) when making API calls, or it will result is very large results and very long execution times. Instead, you should work with the 25 photo limit or set a reasonable limit (e.g. 100 photos) and use pagination to get the next set.

At the end of the result set, you'll see something like:

"paging": {
    "cursors": {
      "before": "xxx", 
      "after": "yyy"
    }, 
    "next": "https://graph.facebook.com/v2.2/000/photos?pretty=0&limit=15&after=yyy"
  }

You can use these to make a subsequent API call to get the next set of photos.

0
Cnu Federer On

You should make use of paging JSON for further results as Niraj said.