3

I've been able to retrieve list of album by using the following:

final Facebook facebook = new FacebookTemplate(facebookAccessToken, appName);

final PagedList<Album> albumList = facebook.mediaOperations().getAlbums();


for (Album album : albumList) {
  if (album.getName().equalsIgnoreCase("Profile Pictures")) {
    PagingParameters pagingParameters = new PagingParameters(NO_OF_FB_PHOTOS, null, null, null);
    final PagedList<org.springframework.social.facebook.api.Photo> profilePhotos = 
                           facebook.mediaOperations().getPhotos(album.getId(), pagingParameters);

I've verified that albumList contains the correct number of albums as in my facebook account and the album ids match. However, the profilePhotos' Photo objects inside the Profile Pictures album contain null images & links; I can only get the ID and createdDate of the Photo objects....

I have obtained the user_photos permission in my client to obtain the access token. And I have also used Facebook's graph explorer to query using this accessToken and I was able to get the photo urls... Can someone please help point out what I'm missing? Thank you soo much

Update: I wonder if it's because of: "the new Facebook API v2.4 changed the way the response is being sent. Now you need to specify in the request url which fields you want the API to return so /me becomes /me?fields=email,name,etc..." (from facebook graph api returns only name and id for some websites)

Community
  • 1
  • 1
user1955934
  • 2,033
  • 1
  • 24
  • 51
  • maybe similar to this problem: https://lingohub.com/blog/2015/12/workaround-for-broken-facebook-oauth-using-spring-social/ ? – Betty St Dec 09 '15 at 11:32
  • 1
    Your suspicion might be correct, if you are indeed using Graph API 2.4 or newer. It can also be what Betty mentions, but I'm not familiar enough with this SDK to lean onto this one. – curveorzos Dec 10 '15 at 18:00

1 Answers1

1

As mentioned in the comments above, v2.4 and up of Facebook's API require you to specify the fields you want in the response in the fields parameter of your request - very few fields are returned by default otherwise, typically just name and id, and sometimes created time, etc

If the SDK you're using hasn't accounted for that in its own code or examples, you can likely just manually add ?fields=X,Y,Z to your call to request fields x,y,z

Igy
  • 43,312
  • 8
  • 86
  • 115