Twitter身份验证问题

时间:2012-01-12 11:37:58

标签: android twitter

我有这个问题在twitter登录android设备(Nexus)给出错误信息显示如下。 在Galaxy选项卡上,它工作正常,但Nexus发生错误。

我正在使用此库:twitter4j-core-2.1.2.jar

以下是我收到错误的代码行:

System.setProperty("twitter4j.oauth.consumerKey", ConstantData.twitter_consumer_key);
System.setProperty("twitter4j.oauth.consumerSecret",ConstantData.twitter_secret_key);
Configuration configuration = new ConfigurationBuilder()
    .setOAuthConsumerKey(ConstantData.twitter_consumer_key)
    .setOAuthConsumerSecret(ConstantData.twitter_secret_key)
    .build();

twitter = new TwitterFactory(configuration).getInstance(new BasicAuthorization(userName, password));
token = twitter.getOAuthAccessToken();

错误日志在这里:

01-19 11:20:27.300: W/System.err(1232):     TwitterException{statusCode=-1, retryAfter=0, rateLimitStatus=null}
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.http.OAuthAuthorization.getOAuthAccessToken(OAuthAuthorization.java:193)
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.Twitter.getOAuthAccessToken(Twitter.java:1623)
01-19 11:20:27.300: W/System.err(1232):     at com.nameapp.LoginTwitter.isAuthentication(LoginTwitter.java:240)
01-19 11:20:27.300: W/System.err(1232):     at com.nameapp.LoginTwitter$1$1.run(LoginTwitter.java:118)
01-19 11:20:27.300: W/System.err(1232):     at java.lang.Thread.run(Thread.java:1019)
01-19 11:20:27.300: W/System.err(1232):     Caused by: TwitterException{statusCode=-1, retryAfter=0, rateLimitStatus=null}
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:316)
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:68)
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:99)
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.http.OAuthAuthorization.getOAuthAccessToken(OAuthAuthorization.java:186)
01-19 11:20:27.300: W/System.err(1232):     ... 4 more
01-19 11:20:27.300: W/System.err(1232):     Caused by: java.io.IOException: Received authentication challenge is null
01-19 11:20:27.300: W/System.err(1232):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:1153)
01-19 11:20:27.300: W/System.err(1232):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:1095)
01-19 11:20:27.300: W/System.err(1232):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1048)
01-19 11:20:27.300: W/System.err(1232):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:726)
01-19 11:20:27.300: W/System.err(1232):     at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:121)
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.internal.http.HttpResponseImpl.<init>(HttpResponseImpl.java:42)
01-19 11:20:27.300: W/System.err(1232):     at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:279)
01-19 11:20:27.300: W/System.err(1232):     ... 7 more
01-19 11:20:27.300: E/Exception E..:(1232):     TwitterException{statusCode=-1, retryAfter=0, rateLimitStatus=null}

1 个答案:

答案 0 :(得分:0)

slideleftIn:        slideleftOut

      

向右滑入       

向右滑动       

getsture detector

@覆盖     public boolean onTouchEvent(MotionEvent event){         return gestureScanner.onTouchEvent(event);     }

类MyGestureDetector扩展SimpleOnGestureListener {

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {

        if (e1 == null || e2 == null) {
            return false;
        } else if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
            return false;
        } else {

            try {
                if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                    if (index < 3) {

                        index++;

                        viewFlipper.setOutAnimation(slideLeftOut);
                        viewFlipper.setInAnimation(slideRightIn);
                        viewFlipper.showNext();

                        swipe = true;

                        // Log.e("Swip", "Left Swipe");
                    }

                } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                    if (index > 0) {

                        index--;

                        viewFlipper.setOutAnimation(slideRightOut);
                        viewFlipper.setInAnimation(slideLeftIn);
                        viewFlipper.showPrevious();

                        swipe = true;

                        // Log.e("Swip", "Right Swipe");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Error in MyGesture", e.toString());
            }
            return true;
        }
    }
}