Twitter写作,我不想陷入twitterException

时间:2013-10-17 07:33:35

标签: android twitter

protected Boolean doInBackground(String... params) {

    // TODO Auto-generated method stub

    // Boolean isSuccess = false;
    Boolean isSuccess;
    Log.d("TAG", "do in background 수행중..");

    Log.d("TAG", "AccessToken :" + STATICVALUES.TWITTER_ACCESS_TOKEN);
    Log.d("TAG", "AccessToken :" + STATICVALUES.TWITTER_ACCESS_TOKEN_SECRET);

    try {

        Log.d("INF", "try start");

        // Consumer key
        String consumerKey = STATICVALUES.consumerKey;
        // Consumer secret
        String consumerSecret = STATICVALUES.consumerSecret;

        Log.d("INF", "key: " + consumerKey);
        Log.d("INF", "secret: " + consumerSecret);

        twitter = new TwitterFactory().getInstance();

        Log.d("INF", "twitterFactory create");

        twitter.setOAuthConsumer(consumerKey, consumerSecret);

        Log.d("INF", "twitter.setOAuthConsumer");

        AccessToken accessToken = new AccessToken(params[0], params[1]);

        Log.d("INF", "AccessToken create");

        twitter.setOAuthAccessToken(accessToken);

        Log.d("INF", "setOAuthAccessToken");

        twitter.updateStatus(params[2]);

        Log.d("INF", "updateStatus");

        Log.e("TAG", "true");

        isSuccess = true;
    } catch (TwitterException e) {

        Log.d("INF", "catch중");

        isSuccess = false;

        e.printStackTrace();

    }

    return isSuccess;

}

Logcat:

here10-17 16:18:24.017: W/System.err(20641): twitter4j.TwitterException: 410:
10-17 16:18:24.017: W/System.err(20641): {"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}
10-17 16:18:24.017: W/System.err(20641):    at twitter4j.http.HttpClient.request(HttpClient.java:318)
10-17 16:18:24.017: W/System.err(20641):    at twitter4j.http.HttpClientWrapper.request(HttpClientWrapper.java:66)
10-17 16:18:24.017: W/System.err(20641):    at twitter4j.http.HttpClientWrapper.post(HttpClientWrapper.java:97)
10-17 16:18:24.017: W/System.err(20641):    at twitter4j.Twitter.updateStatus(Twitter.java:428)
10-17 16:18:24.017: W/System.err(20641):    at com.twitter.twtasyncTask.RegistAsyncTask.doInBackground(RegistAsyncTask.java:119)
10-17 16:18:24.017: W/System.err(20641):    at com.twitter.twtasyncTask.RegistAsyncTask.doInBackground(RegistAsyncTask.java:1)
10-17 16:18:24.022: W/System.err(20641):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-17 16:18:24.022: W/System.err(20641):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-17 16:18:24.022: W/System.err(20641):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-17 16:18:24.022: W/System.err(20641):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
10-17 16:18:24.022: W/System.err(20641):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-17 16:18:24.022: W/System.err(20641):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-17 16:18:24.022: W/System.err(20641):    at java.lang.Thread.run(Thread.java:856)
10-17 16:18:24.042: D/dalvikvm(20641): GC_CONCURRENT freed 1154K, 19% free 26280K/32199K, paused 2ms+3ms, total 26ms
10-17 16:18:24.087: D/SensorManager(20641): registerListener :: handle = 0  name= LSM330DLC Acceleration Sensor delay= 200000 Listener= android.view.OrientationEventListener$SensorEventListenerImpl@438d1520

我有关于updateStatus的问题。 它最多可以处理setOAuthAccessToken。 但是当你面对updateStatus时,要抓住它。 并转到TwitterException410: 我怎样才能解决这个问题? 请帮帮我

1 个答案:

答案 0 :(得分:0)

您的错误日志非常清楚原因:

  

Twitter REST API v1不再有效。请   迁移到API v1.1。 https://dev.twitter.com/docs/api/1.1/overview

您似乎需要更新Twitter4J jar file