I hope you first ask permission to view your profile with facebook, bcz without permission from facebook will not let you get anything.
loginButton.setReadPermissions("public_profile", "email", "user_friends", "user_education_history", "user_hometown", "user_likes", "user_work_history");
or you can also use facebook feedback to get a user profile picture, for example.
private FacebookCallback<LoginResult> mCallBack = new FacebookCallback<LoginResult>() { @Override public void onSuccess(final LoginResult loginResult) { GraphRequest request = GraphRequest.newMeRequest( loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted( JSONObject object, GraphResponse response) { Log.e("response: ", response + ""); try { String id = object.getString("id").toString(); String email = object.getString("email").toString(); String name = object.getString("name").toString(); String profilePicUrl = "https://graph.facebook.com/" + loginResult.getAccessToken().getUserId() + "/picture?type=large"; Log.d("imageFB", profilePicUrl); Log.d("FB_ID:", id); checkFBLogin(id, email, name, profilePicUrl); } catch (Exception e) { e.printStackTrace(); } finish(); } }); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,email,gender,birthday,friends,likes,hometown,education,work"); request.setParameters(parameters); request.executeAsync(); }
Sagar chavada
source share