I want to post to facebook without dialogue, just programmatically, I'm trying with
public void login(CallbackManager callbackManager) { LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d(LOGTAG, "facebook login success"); share("kk"); } @Override public void onCancel() { Log.w(LOGTAG, "facebook login canceled"); share("kk"); } @Override public void onError(FacebookException exception) { Log.e(LOGTAG, "facebook login error"); exception.printStackTrace(); } }); LoginManager.getInstance().logInWithPublishPermissions((Activity) context, Arrays.asList("publish_actions")); } public void share(final String msg) { Log.d(LOGTAG, "facebook sharing new message"); Set<String> permissions = AccessToken.getCurrentAccessToken().getPermissions(); AccessToken accessToken = AccessToken.getCurrentAccessToken(); Bundle postParams = new Bundle(); postParams.putString("name", "yourTitle"); postParams.putString("caption", "yourCaption"); postParams.putString("description", "yourDesc"); postParams.putString("message", "yourMessage"); GraphRequest request = new GraphRequest(accessToken, "me/feed", postParams, HttpMethod.POST, null); AsynTaskGraphRequest asynTaskGraphRequest = new AsynTaskGraphRequest(request); asynTaskGraphRequest.execute(); }
the problem is that when the application is registered on facebook, it shows the message "This does not allow the application to post to facebook", although I use
LoginManager.getInstance().logInWithPublishPermissions((Activity) context, Arrays.asList("publish_actions"));

On the other hand, how can I check if the user was still registered in fb to call logInWithPublishPermissions only once?
Thanks!
source share