Fabric Twitter Android: update status (403 Forbidden)


#1

I try to create login and update status in Twitter. I use Fabrica and Twitter. Permissions: read and write. My code Login:

loginButton.setCallback(new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {
            // Do something with result, which provides a
            // TwitterSession for making API calls
            session = Twitter.getSessionManager().getActiveSession();
            authToken = session.getAuthToken();
            token = authToken.token;
            secret = authToken.secret;

        @Override
        public void failure(TwitterException exception) {
    });

It’s ok, the method success is calling. Next my updateStatus method:

session = Twitter.getSessionManager().getActiveSession();
            TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient(session);
            StatusesService statusesService = twitterApiClient.getStatusesService();
            statusesService.update(strMessage, null, null, null, null, null, null, null, new Callback<Tweet>() {
                @Override
                public void success(Result<Tweet> tweetResult) {
                }

                @Override
                public void failure(TwitterException e) {
                    e.printStackTrace();
                }
            });

all time calling failure method and printStackTrace is next:

    15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ com.twitter.sdk.android.core.TwitterApiException: 403 Forbidden
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:382)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-15 07:48:49.909    1596-1596/com.example.kevinscience.projectv4 W/System.err﹕ at java.lang.Thread.run(Thread.java:841)

Please help me to solve this problem.


#3

First, you may try casting the TwitterException to a TwitterApiException in your failure handler and using the getErrorCode and getErrorMessage methods to get the Twitter error code and message which can sometimes be helpful.


#4