vaksfk / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

ClassCastException when calling FacebookJsonRestClient.photos_getByAlbum #251

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When using the method FacebookJsonRestClient.photos_getByAlbum, version
3.0.0 of the Facebook API throws a ClassCastException:

Caused by: java.lang.ClassCastException: org.json.JSONObject cannot be cast
to org.json.JSONArray
    at
com.google.code.facebookapi.FacebookJsonRestClient.photos_getByAlbum(FacebookJso
nRestClient.java:426)

Original issue reported on code.google.com by Sebastia...@gmail.com on 6 Oct 2009 at 2:26

GoogleCodeExporter commented 8 years ago
apparently, this happens for photo albums that only have a single photo in them;
maybe the JSON parser then returns an object instead of an array. If I manage 
to fix
it, I'll attach a patch.

Original comment by Sebastia...@gmail.com on 6 Oct 2009 at 2:51

GoogleCodeExporter commented 8 years ago
I am guessing your guess if right.. I think I have seen facebook be a bit
inconsistent on json values before.. changing between array and single object. 
:( 
Let me know if that is the issue.

Original comment by fern...@gmail.com on 1 Nov 2009 at 12:51

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It seems that the returned type have to be PhotosGetResponse and not 
List<Photo>.
To be sure I modified my src (in IFacebookRestClient I remove the annotation
"JAXBList = Photo.class" of the two getByAlbum methods) to return an Object and 
it
works :)

regards

Original comment by giovanni...@gmail.com on 10 Nov 2009 at 4:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
What you have to do is:

1. get the latest shapshot from svn
2. change the definition of photos_getByAlbum functions (there are two of them)
3. change @FacebookReturnType(JAXBList = Photo.class, JSON = JSONArray.class) 
to 
this @FacebookReturnType(JAXB = PhotosGetResponse.class, JSON = JSONArray.class)
4. compile the library
5. get the patched target jar files and everything will work fine :-)

i lost two days of work :-(

manos

Original comment by mosch...@gmail.com on 22 Dec 2009 at 2:48

GoogleCodeExporter commented 8 years ago
I confirm the issue and the moschous's report. The attached file is a svn diff 
that corrects the issue.

Original comment by traxt...@gmail.com on 24 Jan 2010 at 9:53

Attachments:

GoogleCodeExporter commented 8 years ago
Wish I had found this issue before I encountered and researched the problem
separately :)  Applied same solution as above.

Original comment by jasper.r...@gmail.com on 11 Mar 2010 at 9:10