I am getting the facebook profile information and also the profile picture.
public void getProfileInformationFacebook(AccessToken accToken) {
GraphRequest request = GraphRequest.newMeRequest(
accToken,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
Log.e("object", object.toString());
String fbId = null;
String fbEmail = null;
String fbName = null;
String fbUrl = null;
try {
fbId = object.getString("id");
fbEmail = object.getString("email");
fbName = object.getString("name");
JSONObject picture = object.getJSONObject("picture");
JSONObject pictureData = picture.getJSONObject("data");
fbUrl = pictureData.getString("url");
} catch (JSONException e) {
e.printStackTrace();
} finally {
regDetails("Facebook", fbId, fbName, fbEmail, fbUrl);
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,location,birthday,picture");
request.setParameters(parameters);
request.executeAsync();
}
The response I receive is this
{"picture":{"data":{"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xfa1\/v\/t1.0-1\/c0.0.50.50\/p50x50\/32044_407244053957_1365573_n.jpg?oh=df9a5f89e6b19af9942cb948c952a026&oe=57559847&__gda__=1465809549_0402ad5c0dcf64f932ceabc982b02f5f","is_silhouette":false}},"id":"10153520390508958","email":"wishygupta@yahoo.com","name":"Wishy Gupta"}
And the profile image I receive from the URL is too small. How to increase its width and height??
You can do this,
fbProfilePicURL = "https://graph.facebook.com/" + fbID + "/picture?type=large&redirect=true";
Just change the type
attribute to anyone of enum{small, normal, album, large, square}
.
Source : Documentation.