spring-attic / spring-social-facebook

Facebook API binding and connect support.
http://projects.spring.io/spring-social-facebook
Apache License 2.0
248 stars 269 forks source link

Album cover photo changed to object in v2.4 #193

Open mflesh1 opened 8 years ago

mflesh1 commented 8 years ago

As of v2.4 of the Facebook graph API the cover_photo of an Album now returns a complex object instead of a string. This causes an issue when using the Album class to fetch an album and specifying the cover_photo field.

For example: new FacebookTemplate("access token here").fetchConnections("facebook", "albums", Album.class, "id,cover_photo")

Error: org.springframework.social.UncategorizedApiException: Error deserializing data from Facebook: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: [{"id":"10150629589136729","cover_photo":{"created_time":"2012-10-04T11:00:54+0000","id":"10151496277356729"}},{"id":"494827881728","cover_photo":{"created_time":"2015-11-14T09:02:14+0000","id":"10154189880711729"}},{"id":"376995711728"},{"id":"10152716010956729","cover_photo":{"created_time":"2014-05-03T00:44:47+0000","id":"10152716011096729"}},{"id":"10151994059021729","cover_photo":{"created_time":"2013-07-01T21:41:44+0000","name":"Mark Zuckerberg and NFL player Brendon Ayanbadejo ride the Facebook Pride trolley. (Photo Credit: Jason Agron Photography)","id":"10151994059346729"}},{"id":"10151908376636729","cover_photo":{"created_time":"2013-05-17T21:35:06+0000","id":"10151908376831729"}},{"id":"10151605031576729","cover_photo":{"created_time":"2012-12-12T21:26:26+0000","name":"Books: \n1. The Hunger Games (The Hunger Games, #1) - Suzanne Collins \n2. Catching Fire (The Hunger Games, #2) - Suzanne Collins \n3. Mockingjay (The Hunger Games, #3) - Suzanne Collins \n4. Fifty Shades of Grey (Fifty Shades, #1) -E.L. James \n5. Harry Potter and the Sorcerer's Stone (Harry Potter, #1) - J.K. Rowling\n6. The Help - Kathryn Stockett \n7. Twilight (Twilight, #1) - Stephenie Meyer \n8. To Kill a Mockingbird - Harper Lee \n9. The Great Gatsby - F. Scott Fitzgerald \n10. Water for Elephants - Sara Gruen","id":"10151605031671729"}},{"id":"10151604842691729"},{"id":"10151604828821729"},{"id":"10151604828741729"},{"id":"10151604813136729"},{"id":"10151604807591729"},{"id":"10151604805241729"},{"id":"10151604804771729"},{"id":"10151604804391729"},{"id":"10151604803671729"},{"id":"10151498615356729"},{"id":"10151498613181729"},{"id":"10151498610756729"},{"id":"10151498609236729"},{"id":"10151498602851729"},{"id":"10151498600496729"},{"id":"10151498599416729"},{"id":"10151498599221729"},{"id":"10151498598821729"}]; line: 1, column: 27] (through reference chain: java.util.ArrayList[0]->org.springframework.social.facebook.api.Album["cover_photo"]) at org.springframework.social.facebook.api.impl.FacebookTemplate.deserializeDataList(FacebookTemplate.java:403) ......

thetminko commented 7 years ago

Any update on this issue?

mouadelmerchi commented 6 years ago

When calling getAlbums() method from MediaOperation object, the new graph API returns this:

{ "id":"1566118282714", "can_upload":false, "count":4, "cover_photo":{ "created_time":"2017-09-07T03:25:08+0000", "id":"01213856982419289" }, "created_time":"2010-09-03T11:47:25+0000", "from":{ "name":"John Doe", "id":"01223467321201970" }, "link": ..., "name":"Album Pictures", "privacy":"everyone", "type":"album type", "updated_time":"2017-11-02T18:33:19+0000" }

The idea is to create a class in the package org.springframework.social.facebook.api named, for example, PhotoReferencethat extends FacebookObject and contains two fields (String id, Date createdTime). Then we can change the type of coverPhoto field, in Album class from Stringto PhotoReference