Reputation: 10068
I have an android app that support facebook login too, and each logged user has a profile picture (custom, or facebook profile picture), and each user is register on my server too. Now if i need to retrieve picture of user friends, i have no problem, because i make everithing inside app by using ProfilePictureView object of last Android Facebook SDK and friends id:
fb_image = (ProfilePictureView) view.findViewById(R.id.fb_friend_thumbnail);
fb_image.setProfileId(friend_id);
If i need to retrieve facebook picture of other user, i call a php script that should return information for get picture. It's a good practice to send user's id as result of script (so app retrieve picture by using ProgilePictureView), or it's better to use php sdk for get picture, encode it and sent it as result?
Upvotes: 0
Views: 413
Reputation: 6899
If you can get user id of facebook friends, then you can get profile picture of users.
Request request = Request.newMeRequest(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// If the response is successful
try {
if (session == Session.getActiveSession()) if (user != null) {
String fbFirstName = user.getFirstName();
String fbLastName = user.getLastName();
String dateOfBirth = user.getBirthday();
String userId=user.getId();
URL image_url=new URL("https://graph.facebook.com/"+ user.getId()+ "/picture?type=small");
Bitmap bitmap=null;
bitmap= BitmapFactory.decodeStream(image_url.openConnection().getInputStream());
String fbEmail = user.asMap().get("email").toString();
Session.getActiveSession()
.closeAndClearTokenInformation();
getActivity().finish();
}
}
catch(Exception e){
Log.e(Constants.TAG_EXCEPTION, e.toString());
}
}
});
request.executeAsync();
}
Upvotes: 1