3

i'm write android app that use facebook api, and i need that my app can retrieve user profile picture.

This is my current permissions:

fb_login_button.setReadPermissions(Arrays.asList("public_profile", "user_friends"));

but i don't see in documentation any permission for get user profile picture, but only permission for access to ALL pictures (i'm not interested about it). So, profile picture is now accessible without any permission

giozh
  • 9,868
  • 30
  • 102
  • 183

2 Answers2

3

The public_profile permission does give you profile picture as well.

This is how you will get the profile picture

public static Bitmap getFacebookProfilePicture(String userID){
URL imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?type=large");
Bitmap bitmap = BitmapFactory.decodeStream(imageUrl.openConnection().getInputStream());

return bitmap;
 }

 Bitmap bitmap = getFacebookProfilePicture(userId);

Refer: Android - get facebook profile picture

Community
  • 1
  • 1
Jazib
  • 1,200
  • 1
  • 16
  • 39
  • so, if i have user id (contains in public_profile information) can i retrieve the profile picture also not from android app (for example from a php script)? – giozh Jul 24 '14 at 09:04
  • 1
    Yes, if you have user id. You can get the profile picture. – Jazib Jul 24 '14 at 09:07
  • This one is not a reliable method, use FQL instead, the facebook Querry Language. I used the same thing and it won't work, once the fb guys update their security... It was working for me earlier, then it showed no pic, then i had to switch to fql... Or another option is to use the FacebookProfilePicView of the Facebook SDK. – Kailas Jul 24 '14 at 09:34
1

You don't need any special permission get the profile picture. Using the permission "public_profile" you can get the user's id. if you have the user id , you can get the profile picture by using the graph api , as follows.

http://graph.facebook.com/user_id/picture?type=square&redirect=false

if you use redirect=false, you will get a json as follows.

{
   "data": {
      "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/t1.0-1/c92.62.775.775/s50x50/564992_463610327023364_1165619683_n.jpg",
      "is_silhouette": false
   }
}

The "url" in the json will give the user's profile picture. You can also use it without reidrect.

JIthin
  • 1,413
  • 1
  • 13
  • 29