I saw lots of questions like this in Stack Overflow but they didn't solve my problem. I referred this, this and also Documentation links like this and this
I used LoginButton
to login in my App.
I am able to get user's (which is logged in) Name, Email, etc,using following code (it works fine):
private FacebookCallback<LoginResult> callback = new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
AccessToken accessToken = loginResult.getAccessToken();
Profile profile = Profile.getCurrentProfile();
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
try {
email = object.getString("email");
} catch (JSONException e) {
e.printStackTrace();
}
Log.e("EMAIL",email);
Log.e("GraphResponse", "-------------" + response.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,link,gender,birthday,email");
request.setParameters(parameters);
request.executeAsync();
}
with permissions:
loginButton.setReadPermissions("user_friends");
loginButton.registerCallback(callbackManager, callback);
I got JSON in LogCat. But now I want to get Friends list, So I wrote code by seeing Documentation and changed my code slightly as follows:
private FacebookCallback<LoginResult> callback = new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
AccessToken accessToken = loginResult.getAccessToken();
Profile profile = Profile.getCurrentProfile();
// I saw following code in Documentation
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{friendlist-id}", /* I actually tried ,friend-list-id' , /me/friends' , '/me/taggable_Friends' and many*/
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
// handle the result
Log.d("RESPONSE KBT",response.toString());
}
}
).executeAsync();
}
with permissions:
loginButton.setReadPermissions(Arrays.asList("email", "user_friends","read_custom_friendlists"));
loginButton.registerCallback(callbackManager, callback);
I get this in my LogCat:
RESPONSE KBT﹕ {Response: responseCode: 404, graphObject: null, error: {HttpStatus: 404, errorCode: 803, errorType: OAuthException, errorMessage: (#803) Some of the aliases you requested do not exist: {friendlist-id}}}