Fabric Twitter Android:仅更新状态一次(403 Forbidden)

时间:2015-03-29 00:39:02

标签: android twitter

我尝试在Twitter中创建登录和更新状态。我使用Fabrica和Twitter。权限:读写。 我的代码登录:

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

没关系,方法成功就是调用。接下来是我的updateStatus方法:

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

当我第一次尝试时 - 一切都没问题,我的状态在twitter上更新了。但是当我下次发布状态时 - 所有时间都在调用失败方法和printStackTrace:

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

我也在updateStatus方法中尝试:

final StatusesService statusesService = Twitter.getInstance().getApiClient().getStatusesService();

为什么我的状态只更新了一次?什么是错误以及如何解决它?

1 个答案:

答案 0 :(得分:0)

你可以尝试这个: 它在我的最后工作

  TwitterApiClient twitterApiClient = Twitter.getApiClient();
            StatusesService statusesService = twitterApiClient.getStatusesService();


            statusesService.update(strMessage, null, null, null, null, null, null, null, new Callback<Tweet>() {
                @Override
                public void success(Result<Tweet> result) {

                }

                @Override
                public void failure(TwitterException e) {

                    e.printStackTrace();
                }
            });