user1955934
user1955934

Reputation: 3495

Spring Social Facebook: Getting Null photo information (urls) Only Id is not null

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)

Upvotes: 3

Views: 650

Answers (1)

Igy
Igy

Reputation: 43816

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

Upvotes: 1

Related Questions