I used facebook 3.6 sdk . i want to get profile picture from graph user , last time i got image but now it returns null Bitmap.
I used following code
I tried to use redirect page "https://fbcdn-profile-a.akamaihd.net/" + USERID + "/picture?type=large" but it didn't work.
It seems that now facebook redirect you to a different page that we cannot guess. Kind of random variables in URL.
So try below method to get the new redirect page provided by facebook.
private String getProfileGif(String userId) throws IOException {
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter("http.protocol.handle-redirects", false);
HttpGet pageToRequest = new HttpGet("http://graph.facebook.com/" + userId + "/picture?type=large");
pageToRequest.setParams(httpParams);
AndroidHttpClient httpClient = AndroidHttpClient
.newInstance("Android");
HttpMessage httpResponse = httpClient.execute(pageToRequest);
Header header = httpResponse.getFirstHeader("location");
if(header != null){
return(header.getValue());
}
return "";
}
This is gonna return you the real gif URL (final URL).
After that, use this new URL to parse your bitmap.
Change from:
URL image_value = new URL("http://graph.facebook.com/"+ user.getId()+ "/picture?type=large");
to
URL image_value = new URL(getProfileGif(user.getId());
Bitmap bmp = BitmapFactory.decodeStream(image_value.openConnection().getInputStream());
PS: Dont execute getProfileGif or any URL request in main thread.
Let me know your results.