Unable To Get Email And Gender And Dob In Facebook Login Android
Im using the latest Facebook sdk in my application i was able only to get the name and the id only but not the other things here is my code enter code here fb_login.setOnClickList
Solution 1:
//Callback registrationLoginManager.getInstance().registerCallback(callbackManager, newFacebookCallback<LoginResult>() {
@OverridepublicvoidonSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
newGraphRequest.GraphJSONObjectCallback() {
@OverridepublicvoidonCompleted(JSONObject object, GraphResponse response) {
try {
fb_id = object.getString("id");
fb_gender = object.getString("gender");
JSONObject obj1 = object.getJSONObject("picture");
JSONObject obj2 = obj1.getJSONObject("data");
fb_name = object.getString("name");
JSONObject obj = object.getJSONObject("age_range");
fb_age = obj.getString("min");
} catch (JSONException e) {
}
}
});
Bundle parameters = newBundle();
parameters.putString("fields", "id,name,gender,age_range,picture");
request.setParameters(parameters);
request.executeAsync();
}
@OverridepublicvoidonCancel() {
// Do Nothing
}
@OverridepublicvoidonError(FacebookException exception) {
// Do NothingLog.e("exception", "->" + exception);
}
});
Solution 2:
You need to request every field you want to have returned specifically.
See the answer at
Post a Comment for "Unable To Get Email And Gender And Dob In Facebook Login Android"