我想在我的 logcat 或其他带有硬编码用户名和密码的时间线上查看我的时间线。我正在使用 Twitter API 和 twitter4j 作为库:这是我当前的代码:
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setDebugEnabled(true);
configurationBuilder.setOAuthConsumerKey(CONSUMER_KEY);
configurationBuilder.setOAuthConsumerSecret(SECRET_KEY);
configurationBuilder.setOAuthAccessToken(ACCESS_TOKEN);
configurationBuilder
.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);
configurationBuilder.setUseSSL(true);
Configuration configuration = configurationBuilder.build();
Twitter twitter = new TwitterFactory(configuration)
.getInstance();
try {
List<Status> statuses = twitter.getHomeTimeline();
Log.d(TAG, "Showing home timeline.");
for (Status status : statuses) {
Log.d(TAG,
status.getUser().getName() + ":"
+ status.getText());
}
} catch (TwitterException e) {
Log.d(TAG, "TwitterException: " + e.toString());
}
CONSUMER_KEY:是我在 dev.twitter.com 中注册我的应用程序时获得的消费者密钥,与 SECRET_KEY、ACCESS_TOKEN 和 ACCESS_TOKEN_SECRET 相同。
这是我的 logcat 输出:
07-24 06:29:16.027: D/FeedsActivity(1621): TwitterException: No authentication challenges found
07-24 06:29:16.027: D/FeedsActivity(1621): Relevant discussions can be found on the Internet at:
07-24 06:29:16.027: D/FeedsActivity(1621): http://www.google.co.jp/search?q=e5488403 or
07-24 06:29:16.027: D/FeedsActivity(1621): http://www.google.co.jp/search?q=0a0b625e
07-24 06:29:16.027: D/FeedsActivity(1621): TwitterException{exceptionCode=[e5488403-0a0b625e 6ece33f2-3760e528], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.3}