I am experiencing some issues with the graph API on iOS.
I am trying to fetch all FB albums from an user. I noticed that by default, the graph API answer 25 first elements and then they provide next and/or previous urls to query the rest.
My problem is that I need to query every elements (not only the first 25) in one shot.
I tried using the limit parameter as explained in Facebook documentation, but I get an empty data array in response. When I remove the limit param, I can grab the 25 first elements.
Facebook API behaves in a similar way when I try with until=today or until=yesterday.
Here is the url I am using:
https://graph.facebook.com/me/albums?limit=0
0 is supposed to means no limit, I tried with 99999 same results.
I was wondering if someone already has that strange behavior from the Graph API?
Thank you for your help!
I finally found the problem.
There is a bug in the social network, it seams that Apple always append the string
"?access_token=[ACCESS_TOKEN]"at the end of the url string.According to that, if you put a parameter before in the URL string, the URL is not a valid as you’ll have two “?” in the string.
To avoid that I am using NSURLConnection class to manage the connection in this way:
First I test the presence of the param character in the string and I append the correct one.
I give you as a bonus the way I handle the error.
I still use the social framework to get the credentials and connect the user:
In this code I don’t handle multiple facebook accounts but you can easily transform that snippet to handle it in your own way. Also, the connection is sent synchronously because I am using GCD to avoid blocking my interface but you can implement an asynchronous method built in the NSURLConnection class.
Hope this will help someone !