0

我正在尝试从 Facebook 获得我的 Android 应用程序的 publish_actions 权限。问题是,当我尝试在我的 Facebook 帐户上发布故事时,它会毫无问题地发布,但是当我尝试在测试用户帐户上发布故事时却没有。Facebook 评论者一直在说;

来自我们审核团队的注释 Android 预期的故事不会发布回 Facebook。我已尝试与不同的测试用户一起重现 publish_actions,但没有发布任何内容。请检查链接并重新提交。还提供发布故事的时间线屏幕截图。确保应用程序未以任何方式预先填写用户消息区域,否则提交将被拒绝。这包括主题标签、URL 和任何其他非用户编写的文本。

我用于登录的代码是;

private void loginToFacebook() {

    cd = new ConnectionDetector(getApplicationContext());

    // Check if Internet present
    if (!cd.isConnectingToInternet()) {
        // Internet Connection is not present
        alert.showAlertDialog(SettingsActivity.this,
                "İnternet Bağlantı Hatası",
                "Lütfen İnternet'e bağlanın", false);

        // stop executing code by return
        return;
    } else {

        // start Facebook Login
        Session.openActiveSession(SettingsActivity.this, true,
                new Session.StatusCallback() {

                    // callback when session changes state
                    @Override
                    public void call(Session session, SessionState state,
                            Exception exception) {
                        if (session.isOpened()) {
                            // make request to the /me API

                            Request.newMeRequest(session,
                                    new Request.GraphUserCallback() {

                                        // callback after Graph API response
                                        // with user object
                                        @Override
                                        public void onCompleted(
                                                GraphUser user,
                                                Response response) {
                                            if (user != null) {
                                                Editor e = facebookPreferences
                                                        .edit();

                                                e.putBoolean(
                                                        PREF_KEY_FACEBOOK_LOGIN,
                                                        true);
                                                e.commit(); // save changes

                                                Intent intent = getIntent();
                                                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                                                finish();
                                                startActivity(intent);
                                            }
                                        }
                                    }).executeAsync();
                        }
                    }
                });
    }
}

我用于共享的代码是;

private static SharedPreferences facebookPreferences, twitterPreferences;
Cursor c, c2;

private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;

private void PublishToFeedInBackground(String quote) {

    Session session = Session.getActiveSession();

    if ((session != null && session.isOpened()) || facebookPreferences.getBoolean(PREF_KEY_FACEBOOK_LOGIN, false)) {
        Toast.makeText(QuoteDialogActivity.this, "Facebook'a gönderiliyor...", Toast.LENGTH_LONG).show();
        onSessionStateChange(session, session.getState(), null);
        // Check for publish permissions
        List<String> permissions = session.getPermissions();
        if (!isSubsetOf(PERMISSIONS, permissions)) {
            pendingPublishReauthorization = true;
            Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this,
                    PERMISSIONS);
            session.requestNewPublishPermissions(newPermissionsRequest);
            return;
        }

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

        Request.Callback callback = new Request.Callback() {

            public void onCompleted(Response response) {

                FacebookRequestError error = response.getError();
                if (error != null) {
                    Toast.makeText(QuoteDialogActivity.this, error.getErrorMessage(), Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(QuoteDialogActivity.this, "Söz başarıyla yayınlandı",
                            Toast.LENGTH_LONG).show();
                }
            }
        };

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

        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
    } else {
        alert.showAlertDialog(QuoteDialogActivity.this, "Login !",
                "Önce ayarlardan Facebook'a giriş yapmalısınız", false);
    }

}

这是一个报价应用程序,它将所选报价发布到登录用户的 Facebook 时间线。

对可能出现的问题有任何帮助吗?

4

0 回答 0