I was trying to use RestFB, but it's just to slow, it was taking about
40secs just to retrieve the albuns covers in a page, so i found
BatchFB, the only problem is: it's way more complex.
So.. my problem is, I can't make anything to work, I aways get this
irritating exception:
Name: org.codehaus.jackson.map.JsonMappingException
Message: "No suitable constructor found for type [simple type, class
controller.Albuns$Album]: can not instantiate from JSON object (need
to add/enable type information?) at [Source: N/A; line: -1, column:
-1] (through reference chain:
com.googlecode.batchfb.type.Paged["data"])".
My code (Both class and method are inside another class):
* Method being executed:
private void recuperarAlbuns(){
Batcher fbBatcher = new FacebookBatcher(MY_ACCESS_TOKEN);
PagedLater<Album> page = fbBatcher.paged(pageName + "/albums",
Album.class);
System.out.println(page.get().size());
}
* class Album:
public class Album{
private String id;
private String name;
private String description;
private String link;
private String type;
private int count;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
Thanks in advance for any answer.
Tiago
You mentioned this:
> I was trying to use RestFB, but it's just to slow, it was taking about
> 40secs just to retrieve the albuns covers in a page, so i found
> BatchFB, the only problem is: it's way more complex.
If you were seeing a fetch of PAGE_ID/albums take 40 seconds,
something was up with either your network connection or Facebook, not
RestFB (or BatchFB). If there was something else going on you didn't
mention that was causing performance problems with RestFB, please let
me know off-chain so we don't totally hijack this thread.
Thanks
Mark
Is it possible to reduce the n+1 requests you have to make by using
the Batch API? https://developers.facebook.com/docs/reference/api/batch/
Both RestFB and BatchFB support this, it should hopefully be a nice
speedup over making lots of individual requests.
Thanks
Mark
Later<List<User>> myFriends = batcher.query(I thought maybe I could do somethinhg like this to fetch all album covers at once, but i didn't find anything about queries at BatchFB's page.
"SELECT uid, first_name, pic_square FROM user WHERE uid IN" +
"(SELECT uid2 FROM friend WHERE uid1 = " + myId + ")", User.class);