user3674194 user3674194 - 2 months ago 6
Android Question

Get Larger Image From Facebook Post?

I'm currently getting the newsfeed of a Facebook user. Currently, I can only retrieve thumbnail images that are associated with links, rather than the full-size image. Does anyone know how to get a larger image?

I've looked at the following posts and tried their solutions; however, the posts seem outdated and the facebook graph api seems to have changed since then:

Facebook Graph API Change: Picture type (size) no longer working?

Facebook API post: How to get larger thumbnail?

Please note that I'm on the me/home edge, so the answer below returns an error. See comments below.

my code is:

params.putString("fields","id,actions,application,caption,created_time,description,from,link,message,message_tags,"
+ "name,object_id,picture,place,source,status_type,story,updated_time,type,status_type,story,to,type,"
+ "updated_time,with_tags");

Answer

Eventually I came to this solution:

1) find the URL of the larger image (see code below)

2) get bitmap from URL and add to application UI.

The code mentioned above:

private String getRealURL(String smallURL){
   if (smallURL.contains("url=http")){
       String[] pieces = smallURL.split("url=");
       pieces[1].replace("%2F", "//");
       pieces[1].replace("%3A", ":");
       Log.e("RealURL1:", pieces[1]);
       return pieces[1];           
   }
   else{
       StringBuilder stringBuilder = new StringBuilder();
       stringBuilder.setLength(0);
       stringBuilder.append("https://graph.facebook.com/");
       stringBuilder.append(item.getObjectID());
       stringBuilder.append("/picture?type=normal&access_token=");
       stringBuilder.append(Session.getActiveSession().getAccessToken());
       Log.e("RealURL2:", stringBuilder.toString());
       return stringBuilder.toString();
   }
}
Comments