Android Twitter Kit3: Sometimes Post Tweet failed with HTTP request failed, Status: 403


#1

Hello there,

I set up my Twitter for Android as followed:

Init:

        Log.w("share","init twitter");
        TwitterConfig config = new TwitterConfig.Builder(this)
                .logger(new DefaultLogger(Log.DEBUG))
                .twitterAuthConfig(new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET))
                .debug(true)
                .build();
        Twitter.initialize(config);

Login:

        loginButton = (TwitterLoginButton) findViewById(R.id.twitter_login_btn);
        loginButton.setCallback(new Callback<TwitterSession>() {
            @Override
            public void success(Result<TwitterSession> result) {
                Log.w("share", "twitter login success");
                // Do something with result, which provides a TwitterSession for making API calls
                TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
                TwitterAuthToken authToken = session.getAuthToken();
                String token = authToken.token;
                String secret = authToken.secret;
                Log.w("share", "Twitter token " + token);
                Log.w("share", "Twitter secret " + secret);
                composeTweet(session, rewardType, rewardString, mContext);

Compose Tweet:

                    session = TwitterCore.getInstance().getSessionManager().getActiveSession();
                    final Intent intent = new ComposerActivity.Builder(this)
                            .session(session)
                            .text((rewardString + getString(R.string.social_text_hashtags)))
                            .createIntent();
                    startActivity(intent);
                    Log.w("share", "Twitter new Intent created");

It works quite well with in the beginning: gets initialized, logged in, composed, shared and posted on my twitter-page. But sometimes - somehow mostly after one successful share, I can’t share again with this error:

E/TweetUploadService: Post Tweet failed
                                                                                                com.twitter.sdk.android.core.TwitterApiException: HTTP request failed, Status: 403

Old posts are mostly related to fabric or twitter-cards, which are no longer active in kit3. Any hint would be appreciated! Thanks!


#2

A couple of days after my last test and my first post above I checked it again from two different devices w/o changing the code in the meantime. And yeah, it works now like a charm! Not sure what caused all the trouble, maybe just some hiccup within the system that special day.


#3

UPDATE: I guess I really figured out now, what was wrong: It seems, that tweets with exactly the same content seem to be blocked, if they are send one after another in a very short period of time. Since my test-tweets just used a defined string every time its clear, that a consecutive second (third, fourth,…) tweet gets denied, immediately after the first tweet passed through. If I just type some additional stuff in the composer on the device all tweets pass through.


#4