0

I read the docs a lot from Facebook, but I don't see something which helps me to get the email or the id.

I searched also in Google but there was nothing helpful.

I have an app to log in and log out, but I need to use the email and the id!

rala
  • 895
  • 2
  • 18
  • 43

1 Answers1

0

To get these information you need to log in using Facebook info, right? OK. Facebook supports you giving you the code to log in. The only person that can give you permission is the user.

Once the user gives you permission to access his info, you can get his email and facebook id very easily.

1 Step -> How to log in in Android apps: https://developers.facebook.com/docs/android/login-with-facebook/v2.1

2 Step -> Permission : https://developers.facebook.com/docs/android/login-with-facebook/v2.1#step3 2.1 "Here's an example that asks for email..."

3- Facebook SDK for Android : https://developers.facebook.com/docs/android/getting-started/

Once you do everything above(It is easier than you think), if I am not wrong(you have to check the right code), you can get userEmail, and userID using a code similar to this:

 if (user != null) {
                TextView welcome = (TextView) findViewById(R.id.welcome);
                welcome.setText("Hello " + user.getName() + "!");

I am sure it is not this way I am doing here, but you can get the email and id easily like this code in here. It is just an example:

email = user.email;
user_ID = user.getId();

This question can help you as well.

I hope it can help you.

Community
  • 1
  • 1
Andressa Pinheiro
  • 1,517
  • 2
  • 18
  • 28
  • how do i get the user object? – rala Aug 18 '14 at 21:19
  • FB has its own code to support programmers to use the login button. The user will be found as a parameter of a function like this: public void onCompleted(GraphUser user, Response response) { if (user != null) { TextView welcome = (TextView) findViewById(R.id.welcome); welcome.setText("Hello " + user.getName() + "!"); } } }).executeAsync(); Once you have a function like this, you can get user. :) source: https://developers.facebook.com/docs/android/getting-started/ – Andressa Pinheiro Aug 19 '14 at 13:37