Skip to content Skip to sidebar Skip to footer

Fetch Facebook User Data

Hey guys I am able to login the user to its facebook account and post a content on his profile. But what i am not able to do is get facebook users information. I dont know where i

Solution 1:

/* this is user defined method  to fetch current user firstnam and last name */publicvoidgetUser(){

    try{
        JSONObject json = Util.parseJson( mFacebook.request("me"));
        String facebookID = json.getString("id");
        String firstName = json.getString("first_name");
        String lastName = json.getString("last_name");
        mFirstName=firstName;
        mLastName=lastName;
        mText.setText("You are logged in : "+mFirstName+"."+mLastName);
        System.out.println("Firstname>>"+firstName+" LastName>>"+lastName);
    }catch (Exception e) {
        // TODO: handle exception
    }catch(FacebookError fbe){

    }
}

Solution 2:

Well i got it.

Facebook sends the access token when the user registers the application and allows the given permissions.

So in my onComplete() method i added this peice of code :

if (values.isEmpty()) {
     return;
}
if (!values.containsKey("post_id")) {
     try {
          Log.d("++++++++++++", facebookClient.getAccessToken());
          Log.d("++++++++++++", facebookClient.request("me"));
     }
}

and in my log it gives me data.

Post a Comment for "Fetch Facebook User Data"