I am new in using facebook api for Android. I am trying to read message from facebook using Graph Api. When I try to pass read_mailbox
permission I get invalid permission error.
Here is the link I tried to refer. https://developers.facebook.com/docs/graph-api/reference/v2.8/user/inbox
Here is the code how I am trying to do so.
loginButton.setReadPermissions(Arrays.asList("public_profile","user_friends","email","user_about_me","read_mailbox"));
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(final LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject json, GraphResponse response) {
if (response.getError() != null) {
System.out.println("ERROR" +response.getError().getErrorMessage());
} else {
System.out.println("Success");
try {
String jsonresult = String.valueOf(json);
System.out.println("JSON Result"+jsonresult);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link,email,inbox");
request.setParameters(parameters);
request.executeAsync();
}
Here is the link for permission which shows that read_mailbox is depricated. https://developers.facebook.com/docs/facebook-login/permissions But what is the alternative to this. I Also wanted to send message, but I stuck here only. Any help is appriciated.
Thanks in advance
read_mailbox
is deprecated and there is no alternative. It is not possible to read the user mailbox anymore.
Sending a message is easy with the Send Dialog: https://developers.facebook.com/docs/sharing/reference/send-dialog
...or the Message Dialog on Android: https://developers.facebook.com/docs/sharing/android#message