mzeki
mzeki

Reputation: 33

Facebook Publish Permissions

I'm trying to get the publish_actions permission from Facebook for my Android App. The problem is that when I try to publish the story on my Facebook account it publishes without any problem but when I try to publish the same on a test user account it does not. Facebook reviewers keep saying;

Notes from our review team Android The expected story doesn't publish back to Facebook. I've tried with different test users to reproduce the publish_actions, but nothing is publishing. Please check links and resubmit. Also provide a timeline screenshot of the publish story. Make sure the user message area is not pre-filled in any way by the app otherwise the submission will be rejected. This includes hashtags, URLs, and any other text not written by the user.

Code I use for login is;

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();
                        }
                    }
                });
    }
}

Code I use for sharing is;

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);
    }

}

This is a quote app which publishes a selected quote to the Facebook timeline of the logged in user.

Any help on what may be wrong?

Upvotes: 0

Views: 295

Answers (0)

Related Questions