diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/Album.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/Album.java index d74f635ca..2781e9cc2 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/Album.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/Album.java @@ -30,7 +30,7 @@ public class Album extends FacebookObject { private int count; - private String coverPhoto; + private Photo coverPhoto; private Date createdTime; @@ -52,6 +52,8 @@ public class Album extends FacebookObject { private Date updatedTime; + private Date backdatedTime; + public String getId() { return id; } @@ -68,7 +70,7 @@ public int getCount() { * The ID of the Photo object that is the cover photo for the album. * @return A Photo object ID or null if the album does not have a cover photo */ - public String getCoverPhoto() { + public Photo getCoverPhoto() { return coverPhoto; } @@ -112,6 +114,10 @@ public Date getUpdatedTime() { return updatedTime; } + public Date getBackdatedTime() { + return backdatedTime; + } + public static enum Type { APP, COVER, PROFILE, MOBILE, WALL, NORMAL, ALBUM, UNKNOWN } public static enum Privacy { EVERYONE, FRIENDS_OF_FRIENDS, FRIENDS, CUSTOM } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java index 7f717849a..5c54a366c 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java @@ -162,6 +162,6 @@ public interface GraphApi { */ String getApplicationNamespace(); - static final String GRAPH_API_URL = "https://graph.facebook.com/v2.3/"; + static final String GRAPH_API_URL = "https://graph.facebook.com/v2.4/"; } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/MediaTemplate.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/MediaTemplate.java index 4fb2423de..3d66cf709 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/MediaTemplate.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/MediaTemplate.java @@ -55,8 +55,8 @@ public PagedList getAlbums(String userId) { return getAlbums(userId, new PagingParameters(25, 0, null, null)); } - public PagedList getAlbums(String userId, PagingParameters pagedListParameters) { - return graphApi.fetchConnections(userId, "albums", Album.class, getPagingParameters(pagedListParameters)); + public PagedList getAlbums(String userId, PagingParameters pagingParameters) { + return graphApi.fetchConnections(userId, "albums", Album.class, pagingParameters.toMap(), ALBUM_FIELDS); } public Album getAlbum(String albumId) { @@ -87,7 +87,7 @@ public PagedList getPhotos(String objectId) { } public PagedList getPhotos(String objectId, PagingParameters pagedListParameters) { - return graphApi.fetchConnections(objectId, "photos", Photo.class, getPagingParameters(pagedListParameters)); + return graphApi.fetchConnections(objectId, "photos", Photo.class, getPagingParameters(pagedListParameters), PHOTO_FIELDS); } public Photo getPhoto(String photoId) { @@ -175,4 +175,7 @@ public void tagVideo(String videoId, String userId) { data.add("tag_uid", userId); graphApi.publish(videoId, "tags", data); } + + private static final String PHOTO_FIELDS = "id,album,backdated_time,backdated_time_granularity,created_time,from,height,icon,images,link,name,page_story_id,place,picture,source,tags,updated_time,width"; + private static final String ALBUM_FIELDS = "id,can_upload,count,cover_photo{" + PHOTO_FIELDS + "},created_time,from,link,name,privacy,type,updated_time,likes,comments,backdated_time"; } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/json/AlbumMixin.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/json/AlbumMixin.java index 4ba881ef7..feb6339a7 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/json/AlbumMixin.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/json/AlbumMixin.java @@ -81,6 +81,9 @@ abstract class AlbumMixin extends FacebookObjectMixin { @JsonProperty("updated_time") Date updatedTime; + @JsonProperty("backdated_time") + Date backdatedTime; + private static class TypeDeserializer extends JsonDeserializer { @Override public Type deserialize(JsonParser jp, DeserializationContext ctxt) diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java index 95402697f..c946d2286 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java @@ -32,7 +32,7 @@ public class MediaTemplateTest extends AbstractFacebookApiTest { @Test public void getAlbums() { - mockServer.expect(requestTo(fbUrl("me/albums?offset=0&limit=25"))) + mockServer.expect(requestTo(fbUrl("me/albums?limit=25&offset=0&fields=id%2Ccan_upload%2Ccount%2Ccover_photo%2Ccreated_time%2Cfrom%2Clink%2Cname%2Cprivacy%2Ctype%2Cupdated_time%2Clikes%2Ccomments%2Cbackdated_time"))) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("albums"), MediaType.APPLICATION_JSON)); @@ -42,7 +42,7 @@ public void getAlbums() { @Test public void getAlbums_forSpecificUser() { - mockServer.expect(requestTo(fbUrl("192837465/albums?offset=0&limit=25"))) + mockServer.expect(requestTo(fbUrl("192837465/albums?limit=25&offset=0&fields=id%2Ccan_upload%2Ccount%2Ccover_photo%2Ccreated_time%2Cfrom%2Clink%2Cname%2Cprivacy%2Ctype%2Cupdated_time%2Clikes%2Ccomments%2Cbackdated_time"))) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("albums"), MediaType.APPLICATION_JSON));