gpt4 book ai didi

java - 如何使用 Twitter4j 显示推文

转载 作者:行者123 更新时间:2023-12-01 14:47:06 26 4
gpt4 key购买 nike

我已经遵循了本教程 http://www.javacodegeeks.com/2012/03/twitter-api-on-your-java-application.html并做了完全相同的事情。但我收到如下所示的错误。我错过了什么吗?我应该在任何文件中设置一些权限吗?我检查了很多地方,但仍然无法解决这个问题。请帮忙

Exception in thread "main" 401:Authentication credentials   
(https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set
valid conumer key/secret, access token/secret, and the system clock in in sync.
error - Not authorized
request - /1/statuses/user_timeline.json?
TwitterException{exceptionCode=[ced778ef-115a04e4], statusCode=401, retryAfter=-1,
rateLimitStatus=RateLimitStatusJSONImpl{remainingHits=145, hourlyLimit=150,
resetTimeInSeconds=1362901, secondsUntilReset=1235, resetTime=Sun Mar 10 13:15:51 IST
2013}, featureSpecificRateLimitStatus=null, version=2.2.5}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:185)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:85)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1895)
at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:254)
at com.jdwb.twitterapi.tweet.main(tweet.java:33)
<小时/>
 public class tweet {
public static void main(String[] args) throws TwitterException {
Twitter twitter = new TwitterFactory().getInstance();

ResponseList < Status > a = twitter.getUserTimeline(new Paging(1, 5));
for (Status b: a) {
System.out.println(b.getText());
}
}
}



-------------------------Properties file-------------

debug=true
oauth.consumerKey=***************
oauth.consumerSecret=***********
oauth.accessToken=*******************
oauth.accessTokenSecret=***********************
<小时/>
[Sun Mar 10 14:41:26 IST 2013]status: 401 Unauthorized
[Sun Mar 10 14:41:26 IST 2013]x-ratelimit-remaining: 143
[Sun Mar 10 14:41:26 IST 2013]content-encoding: gzip
[Sun Mar 10 14:41:26 IST 2013]date: Sun, 10 Mar 2013 09:11:26 GMT
[Sun Mar 10 14:41:26 IST 2013]x-ratelimit-reset: 1362908664
[Sun Mar 10 14:41:26 IST 2013]x-transaction: 58f6c286bb1aa6de
[Sun Mar 10 14:41:26 IST 2013]pragma: no-cache
[Sun Mar 10 14:41:26 IST 2013]cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
[Sun Mar 10 14:41:26 IST 2013]{"request":"\/1\/statuses\/user_timeline.json?include_rts=true&include_entities=true&include_my_retweet=1&count=5&page=1","error":"Not authorized"}

Exception in thread "main" 401:Authentication credentials
(https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have
set valid conumer key/secret, access token/secret, and the system clock in in sync.
error - Not authorized

最佳答案

我认为您没有正确设置授权

看看here了解如何设置属性文件。

您需要注册 twitter dev获取您的 API key ,以便您可以填写所需的信息。

关于java - 如何使用 Twitter4j 显示推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15319971/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com