简体   繁体   中英

Posting text on wall: the user hasn't authorized the application to perform this action facebook in android

I know this question has been asked many times before. But none of those answers are working for me.When iam logging in with different user,error is shown.If login with credentials admin of this app,posting on wall is working fine.Please try solve this issue.

Here is my code:

if (isFB) { // calling FB login

        Session session = new Session(this);
        Session.setActiveSession(session);

        Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

        Session.StatusCallback statusCallback = new Session.StatusCallback() {
            @Override
            public void call(Session session, SessionState state,
                    Exception exception) {
                String message = "Facebook session status changed - "
                        + session.getState() + " - Exception: " + exception;
                // Toast.makeText(FacebookShareActivity.this, message,
                // Toast.LENGTH_SHORT).show();
                Log.w("Facebook test", message);

                if (session.isOpened()
                        || session.getPermissions().contains(
                                "publish_actions")) {
                    publishToWall();
                } else if (session.isOpened()) {
                    OpenRequest open = new OpenRequest(
                    RegisterActivity.this).setCallback(this);
                    List<String> permission = new ArrayList<String>();
                    permission.add("publish_actions");
                    open.setPermissions(permission);
                    Log.w("Facebook test", "Open for publish");
                    session.openForPublish(open);
                }
            }
        };

        if (!session.isOpened() && !session.isClosed()
                && session.getState() != SessionState.OPENING) {
            session.openForRead(new Session.OpenRequest(this)
                    .setCallback(statusCallback));
        } else {
            Log.w("Facebook test", "Open active session");
            Session.openActiveSession(this, true, statusCallback);
        }
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Session.getActiveSession().onActivityResult(this, requestCode,
            resultCode, data);
}
void publishToWall() {
    Session session = Session.getActiveSession();

    Bundle postParams = new Bundle();
    postParams.putString("message", "hi");

    Request request = new Request(Session.getActiveSession(), "me/feed",
            postParams, HttpMethod.POST, callback);

    RequestAsyncTask task = new RequestAsyncTask(request);
    task.execute();
}

From v2.0 onwards, the permissions other than public_profile , email and the user_friends must be submitted for review to facebook. After it approved then only the users other than developer/tester/admin can use its functionality.

See here for more detials on Login Submission.

Also, before testing with other users make sure to make your app live -

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM