twitter4j.TwitterException:401:身份验证凭据丢失或不正确

时间:2010-09-03 14:49:05

标签: java gwt twitter

我正在开发基于Web的Java应用程序[GWT] 我在TwitterException面临问题 我使用了有效的凭证 Twitter twitter =新推特(myTwitterId,myTwiterPwd);
当我调用twitter.getFollowers()方法

我收到了以下错误消息

twitter4j.TwitterException: 401:Authentication credentials were missing or incorrect.

<?xml version="1.0" encoding="UTF-8"?>
<errors>
    <error code="53">Basic authentication is not supported</error>
</errors>

    at twitter4j.http.HttpClient.httpRequest(HttpClient.java:469)
    at twitter4j.http.HttpClient.get(HttpClient.java:412)
    at twitter4j.Twitter.get(Twitter.java:276)
    at twitter4j.Twitter.get(Twitter.java:228)
    at twitter4j.Twitter.getFollowersStatuses(Twitter.java:1363)
    at twitter4j.Twitter.getFollowers(Twitter.java:1350)
    at com.vaibhav.dealelephant.server.impl.TwitterServiceImpl.getTwitterFollowers(TwitterServiceImpl.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)

我想在我的网站中显示我的粉丝图片,但在调用此方法 twitter.getFollowers()方法后会抛出异常。所以无法得到我的follwers图像:(

请为我提供简单的解决方案

希望与您一起进行最佳合作

提前致谢!!!

3 个答案:

答案 0 :(得分:5)

答案 1 :(得分:3)

您发布的代码与我过去看到的用于连接的代码不同。我认为(虽然我不确定)oAuth是现在认证的首选方式。

Here's a blog that details using oAuth to connect.

答案 2 :(得分:0)

我遇到了麻烦,最后的解决办法是在我的twitter API(https://dev.twitter.com/)中放置一个有效的回拨网址,我使用google + url,保存更改(可能需要几分钟才能进行更改)制作,刷新页面以确定)并且它有效。