0

i am using facebook4j to load home posts facebook.getHome() and i am getting the profile image and the post image as follows:

facebook4j.User fromUser = facebook.getUser(fbHomePost.getFrom().getId(), 
new Reading().fields("picture"));
if (fromUser.getPicture() != null)                      
  facebookUserPostDto.setProfileImage(fromUser.getPicture().getURL().toURI().toString());
if (fbHomePost.getPicture() != null)
  facebookUserPostDto.setImageLocation(fbHomePost.getPicture().toURI().toString());

all is working well, but the image i am getting from the URLs are small and have low resolution. any idea how to get the "large" images from facebook using facebook4j API? facebook can provide different image sizes API Reference › Graph API › Pictures

thanks

Sameeh Harfoush
  • 610
  • 1
  • 8
  • 22
  • no one ever used facebook4j? – Sameeh Harfoush Apr 16 '13 at 09:41
  • I have integrated facebook4j, but I am getting duplicate feeds. Can you please help me for this : http://stackoverflow.com/questions/16293540/facebook-feed-integration-with-android-app-feeds-getting-duplicated ? – YuDroid May 01 '13 at 06:02

2 Answers2

0

ok i got a reply from the facebook4j google group on how to go this retrieve different image size from my facebook posts

Sameeh Harfoush

Brate

indivisible
  • 4,892
  • 4
  • 31
  • 50
Sameeh Harfoush
  • 610
  • 1
  • 8
  • 22
0

OK first you have to add user_photos to your scope and make sure you are using a valid acces token NOT a Graph API Explorer Token

OAuthService service = new ServiceBuilder()
                                      .provider(FacebookApi.class)
                                      .apiKey(apiKey)
                                      .apiSecret(apiSecret)
                                      .callback("xxxx")
                                      .scope("publish_actions,user_photos ")
                                      .build();

then try this : (tested)

for(Post p : feed){
        System.out.println("********************");
        String type = p.getType();
        System.out.println("type :"+type);
        String idPicVid = p.getObjectId();
        if(type.matches("photo")){
           System.out.println("idPicVid "+idPicVid);
                try{
                    Photo pic = facebook.getPhoto(idPicVid);
                    System.out.println(pic.toString());
                    System.out.println("source "+pic.getSource());
                    System.out.println("picture "+pic.getPicture());
                }catch (Exception e) {
                    e.printStackTrace();
                }
        }
}
Khalil Kitar
  • 331
  • 4
  • 8