- Home /
Facebook API returning always empty data
I am trying to use some picures from facebook inside my unity project. The project is setup right, I can login, receive the friend list and can upload pictures. But the following API call always return an empty data object:
// get all albums
FB.API("me/albums?fields=id", Facebook.HttpMethod.GET, GetAllAlbumsCallback);
// or get all pictures
FB.API("me/pictures?fields=id", Facebook.HttpMethod.GET, GetAllAlbumsCallback);
The result is always
{"data":[]}
without any errors. When I try the same API calls in the Graph API Explorer, I get the IDs as expected. I am also using the user_photos permission, which seems to work in general since I can upload pictures.
Anybody ran into the same problem and knows a work arround?
Answer by vuha.1028 · Jun 27, 2014 at 08:30 AM
You have to set permission "user_photos" to access to album of you and your friends
Please read more carefully, doing that already:
I am also using the user_photos permission, which seems to work in general since I can upload pictures.
How to get user_photos permissions to upload a photo from my application ?
by default, facebook is not giving access for user_photos.
Thank you.
You get the permissions when logging in to facebook, i.e.:
FB.Login("user_photos", LoginCallback);
Source. At the end of this page, you can also find an example of how to check your permissions inside the app (i.e. to log and check):
FB.API("/me/permissions", Http$$anonymous$$ethod.GET, delegate (FBResult response) {
// inspect the response and adapt your UI as appropriate
// check response.Text and response.Error
});
For me it did not work for a while because the debug tokens got mixed up somehow. In the browser I had all necessary permissions, in my app I did not. I reset the tokens and it finally worked in the app too.