twitter search api v1.1 - TwitterException {exceptionCode =

时间:2013-06-16 20:38:15

标签: android

我的应用程序通过Twitter验证,并将控制权返回给我的应用程序。但是当涉及搜索推文时,我收到以下错误:

No authentication challenges found  Relevant discussions can be
> found on the Internet at:     http://www.google.co.jp/search?q=d35baff5
> or    http://www.google.co.jp/search?q=12c94143 
> TwitterException{exceptionCode=[d35baff5-12c94143 43208640-465ee2e3],
> statusCode=-1, message=null, code=-1, retryAfter=-1,
> rateLimitStatus=null, version=3.0.3}      at
> twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:192)
>   at
> twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
>   at
> twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:81)
>   at twitter4j.TwitterImpl.get(TwitterImpl.java:1835)     at
> twitter4j.TwitterImpl.search(TwitterImpl.java:282)    at
> com.leccion.herencia.Alar$5.run(Alar.java:239)    at
> java.lang.Thread.run(Thread.java:864)  Caused by: java.io.IOException:
> No authentication challenges found    at
> libcore.net.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:427)
>   at
> libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:407)
>   at
> libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:356)
> at
> libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:292)

Y el codigo de mi app es:

final Twitter twitter = TwitterFactory.getSingleton();  
            twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
            twitter.setOAuthAccessToken(accessToken); 
            final Query query = new Query("source:twitter4j api"); 

             new Thread(new Runnable() {
                    public void run() {                     
                        try {

         result = twitter.search(query); ***//el error en esta linea!!!***

                             for (Status status : result.getTweets())
                             {
                                    System.out.println("@" + status.getUser().getScreenName() + ":" + status.getText());


                }

1 个答案:

答案 0 :(得分:0)

我要经历同样的问题。您还需要设置访问令牌和令牌密钥。它在Twitter网站上的twitter应用程序中列出了您的消费者密钥和秘密。所以共设4个。之后我就开始工作了。

我有一个关于如何通过手动构建链接并自己解析json而不是使用库来使用v1.1 api的问题。没有教程解释如何做到这一点。