Android Facebook 4.0 Sdk How to Get Email, Date of Birth and Gender of User

How to get user Gender and birthday from facebook in android

  • Facebook gender & birthday needs app review.

Apps that Require App Review

Your app requires review if it uses the following functionality:

Facebook Login and also asks for a person's birthday, location, hometown, gender, age range, or link to profile

  • Check the link for more details.

How to get user email and birthday from Facebook API Version v2.4

You'll have to explicitly define which fields you want to retrieve with your request, for example /me?fields=id,name,email,birthday instead of just /me

See

  • https://developers.facebook.com/docs/apps/changelog#v2_4

To try to improve performance on mobile networks, Nodes and Edges in v2.4 requires that you explicitly request the field(s) you need for your GET requests. For example, GET /v2.4/me/feed no longer includes likes and comments by default, but GET /v2.4/me/feed?fields=comments,likes will return the data. For more details see the docs on how to request specific fields.

Facebook Android SDK 4.14.0 get birthday

According to the latest sdk of facebook, to get birthday you need to first submit your application for review. On test applications you can just get the public profile which includes the following things

  • id
  • cover
  • name
  • first_name
  • last_name
  • age_range
  • link
  • gender
  • locale
  • picture
  • timezone
  • updated_time
  • verified

For more information you can read the following documentation from this link

Does anyone know how to get firstname, lastname, email, id, birthday, gender, hometown, age and etc from facebook sdk in android platform?

Please try this code .Hope it will fetch all the data you needed.Thanx

 public void onSuccess(final LoginResult loginResult) {
Log.e("bug", "facebook sign in success");

if (loginResult != null) {

Profile profile = Profile.getCurrentProfile();

if (profile != null) {
firstName = profile.getFirstName();
lastName = profile.getLastName();
social_id = profile.getId();
profileURL = String.valueOf(profile.getProfilePictureUri(200, 200));
Log.e(TAG, "social Id: " + profileURL);
}

GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.e("bug", "facebook social_id=>" + social_id + " toeken" + loginResult.getAccessToken().getToken());
Log.e("bug", "graph response=>" + object.toString());
try {
if (object.has("name")) {
String[] name = object.getString("name").split(" ");
firstName = name[0];
lastName = name[1];
}
email = object.has("email") ? object.getString("email") : "";
social_id = object.has("id") ? object.getString("id") : "";
socialSignUp("facebook");
} catch (JSONException e) {
e.printStackTrace();
}
}
});

Bundle parameters = new Bundle();
parameters.putString("fields", "id,first_name,name,last_name,email,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
}


Related Topics



Leave a reply



Submit