我开始使用 twitter4J 3.0.4-SNAPSHOT 但使用简单代码时出现错误:
Twitter twitter = TwitterFactory.getSingleton();
try {
Status status = twitter.updateStatus("test");
} catch (TwitterException e) {
e.printStackTrace();
}
OAuth 设置(consumerKey、consumerSecret、accessToken 和 accessTokenSecret)写在类路径中的 twitter4j.properties 中,并且这些值被粗暴地读取,因为当我明确设置它们时,就像twitter.setOAuthConsumer(...)
我被告知它们已经设置一样。在代码中明确设置它们并不会改变这种情况。
我能做些什么?这些值只是错误的还是其他原因?
我试了几次都没有结果...
这是标题信息。
[Wed Jan 23 08:41:51 JST 2013]debug: true
[Wed Jan 23 08:41:51 JST 2013]userAgent: twitter4j http://twitter4j.org/ /3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)
[Wed Jan 23 08:41:51 JST 2013]user: null
[Wed Jan 23 08:41:51 JST 2013]password: null
[Wed Jan 23 08:41:51 JST 2013]useSSL: false
[Wed Jan 23 08:41:51 JST 2013]prettyDebug: false
[Wed Jan 23 08:41:51 JST 2013]gzipEnabled: true
[Wed Jan 23 08:41:51 JST 2013]httpProxyHost: null
[Wed Jan 23 08:41:51 JST 2013]httpProxyUser: null
[Wed Jan 23 08:41:51 JST 2013]httpProxyPassword: null
[Wed Jan 23 08:41:51 JST 2013]httpProxyPort: -1
[Wed Jan 23 08:41:51 JST 2013]httpConnectionTimeout: 20000
[Wed Jan 23 08:41:51 JST 2013]httpReadTimeout: 120000
[Wed Jan 23 08:41:51 JST 2013]httpStreamingReadTimeout: 40000
[Wed Jan 23 08:41:51 JST 2013]httpRetryCount: 0
[Wed Jan 23 08:41:51 JST 2013]httpRetryIntervalSeconds: 5
[Wed Jan 23 08:41:51 JST 2013]maxTotalConnections: 20
[Wed Jan 23 08:41:51 JST 2013]defaultMaxPerRoute: 2
[Wed Jan 23 08:41:51 JST 2013]oAuthConsumerKey: u3T6gYq17fBjQ1xrnm8g
[Wed Jan 23 08:41:51 JST 2013]oAuthConsumerSecret: *******************************************
[Wed Jan 23 08:41:51 JST 2013]oAuthAccessToken: 6588392-YmeaLWSLJcDqswQDL8sdqrnoBcbr0Ht7CSLYDiRmpg
[Wed Jan 23 08:41:51 JST 2013]oAuthAccessTokenSecret: ******************************************
[Wed Jan 23 08:41:51 JST 2013]oAuthRequestTokenURL: http://api.twitter.com/oauth/request_token
[Wed Jan 23 08:41:51 JST 2013]oAuthAuthorizationURL: http://api.twitter.com/oauth/authorize
[Wed Jan 23 08:41:51 JST 2013]oAuthAccessTokenURL: http://api.twitter.com/oauth/access_token
[Wed Jan 23 08:41:51 JST 2013]oAuthAuthenticationURL: http://api.twitter.com/oauth/authenticate
[Wed Jan 23 08:41:51 JST 2013]restBaseURL: http://api.twitter.com/1.1/
[Wed Jan 23 08:41:51 JST 2013]streamBaseURL: https://stream.twitter.com/1.1/
[Wed Jan 23 08:41:51 JST 2013]userStreamBaseURL: https://userstream.twitter.com/1.1/
[Wed Jan 23 08:41:51 JST 2013]siteStreamBaseURL: https://sitestream.twitter.com/1.1/
[Wed Jan 23 08:41:51 JST 2013]dispatcherImpl: twitter4j.internal.async.DispatcherImpl
[Wed Jan 23 08:41:51 JST 2013]loggerFactory: null
[Wed Jan 23 08:41:51 JST 2013]asyncNumThreads: 1
[Wed Jan 23 08:41:51 JST 2013]contributingTo: -1
[Wed Jan 23 08:41:51 JST 2013]includeRTsEnabled: true
[Wed Jan 23 08:41:51 JST 2013]includeEntitiesEnabled: true
[Wed Jan 23 08:41:51 JST 2013]includeMyRetweetEnabled: true
[Wed Jan 23 08:41:51 JST 2013]jsonStoreEnabled: false
[Wed Jan 23 08:41:51 JST 2013]mbeanEnabled: false
[Wed Jan 23 08:41:51 JST 2013]userStreamRepliesAllEnabled: false
[Wed Jan 23 08:41:51 JST 2013]stallWarningsEnabled: true
[Wed Jan 23 08:41:51 JST 2013]mediaProvider: TWITTER
[Wed Jan 23 08:41:51 JST 2013]mediaProviderAPIKey: null
[Wed Jan 23 08:41:51 JST 2013]mediaProviderParameters: null
[Wed Jan 23 08:41:51 JST 2013]clientVersion: 3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)
[Wed Jan 23 08:41:51 JST 2013]clientURL: http://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3).xml
[Wed Jan 23 08:41:51 JST 2013]DALVIK: twitter4j.dalvik
[Wed Jan 23 08:41:51 JST 2013]GAE: twitter4j.gae
[Wed Jan 23 08:41:51 JST 2013]DEFAULT_OAUTH_REQUEST_TOKEN_URL: http://api.twitter.com/oauth/request_token
[Wed Jan 23 08:41:51 JST 2013]DEFAULT_OAUTH_AUTHORIZATION_URL: http://api.twitter.com/oauth/authorize
[Wed Jan 23 08:41:51 JST 2013]DEFAULT_OAUTH_ACCESS_TOKEN_URL: http://api.twitter.com/oauth/access_token
[Wed Jan 23 08:41:51 JST 2013]DEFAULT_OAUTH_AUTHENTICATION_URL: http://api.twitter.com/oauth/authenticate
[Wed Jan 23 08:41:51 JST 2013]DEFAULT_REST_BASE_URL: http://api.twitter.com/1.1/
[Wed Jan 23 08:41:52 JST 2013]DEFAULT_STREAM_BASE_URL: https://stream.twitter.com/1.1/
[Wed Jan 23 08:41:52 JST 2013]DEFAULT_USER_STREAM_BASE_URL: https://userstream.twitter.com/1.1/
[Wed Jan 23 08:41:52 JST 2013]DEFAULT_SITE_STREAM_BASE_URL: https://sitestream.twitter.com/1.1/
[Wed Jan 23 08:41:52 JST 2013]IS_DALVIK: false
[Wed Jan 23 08:41:52 JST 2013]IS_GAE: false
[Wed Jan 23 08:41:52 JST 2013]serialVersionUID: -6610497517837844232
[Wed Jan 23 08:41:52 JST 2013]dalvikDetected: false
[Wed Jan 23 08:41:52 JST 2013]gaeDetected: false
[Wed Jan 23 08:41:52 JST 2013]requestHeaders: {X-Twitter-Client-URL=http://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3).xml, X-Twitter-Client=Twitter4J, Accept-Encoding=gzip, User-Agent=twitter4j http://twitter4j.org/ /3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3), X-Twitter-Client-Version=3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)}
[Wed Jan 23 08:41:52 JST 2013]instances: [ConfigurationBase{debug=true, userAgent='twitter4j http://twitter4j.org/ /3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)', user='null', password='null', useSSL=false, prettyDebug=false, gzipEnabled=true, httpProxyHost='null', httpProxyUser='null', httpProxyPassword='null', httpProxyPort=-1, httpConnectionTimeout=20000, httpReadTimeout=120000, httpStreamingReadTimeout=40000, httpRetryCount=0, httpRetryIntervalSeconds=5, maxTotalConnections=20, defaultMaxPerRoute=2, oAuthConsumerKey='u3T6gYq17fBjQ1xrnm8g', oAuthConsumerSecret='5GLiKBRtILkqIWAA305yJk6lfF4PEdqtzW0ZOKOo1i8', oAuthAccessToken='6588392-YmeaLWSLJcDqswQDL8sdqrnoBcbr0Ht7CSLYDiRmpg ', oAuthAccessTokenSecret='EaMAvSCrQl7qOwJkABZyKCLcabZZ5INd0KB1JKqEes', oAuthRequestTokenURL='http://api.twitter.com/oauth/request_token', oAuthAuthorizationURL='http://api.twitter.com/oauth/authorize', oAuthAccessTokenURL='http://api.twitter.com/oauth/access_token', oAuthAuthenticationURL='http://api.twitter.com/oauth/authenticate', restBaseURL='http://api.twitter.com/1.1/', streamBaseURL='https://stream.twitter.com/1.1/', userStreamBaseURL='https://userstream.twitter.com/1.1/', siteStreamBaseURL='https://sitestream.twitter.com/1.1/', dispatcherImpl='twitter4j.internal.async.DispatcherImpl', loggerFactory='null', asyncNumThreads=1, contributingTo=-1, includeRTsEnabled=true, includeEntitiesEnabled=true, includeMyRetweetEnabled=true, jsonStoreEnabled=false, mbeanEnabled=false, userStreamRepliesAllEnabled=false, stallWarningsEnabled=true, mediaProvider='TWITTER', mediaProviderAPIKey='null', mediaProviderParameters=null, clientVersion='3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)', clientURL='http://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3).xml', IS_DALVIK=false, IS_GAE=false, requestHeaders={X-Twitter-Client-URL=http://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3).xml, X-Twitter-Client=Twitter4J, Accept-Encoding=gzip, User-Agent=twitter4j http://twitter4j.org/ /3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3), X-Twitter-Client-Version=3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)}}]
[Wed Jan 23 08:41:52 JST 2013]Request:
[Wed Jan 23 08:41:52 JST 2013]POST http://api.twitter.com/1.1/statuses/update.json
[Wed Jan 23 08:41:52 JST 2013]OAuth base string: POST&http%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&include_entities%3D1%26include_rts%3D1%26oauth_consumer_key%3Du3T6gYq17fBjQ1xrnm8g%26oauth_nonce%3D3206276498%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1358898112%26oauth_token%3D6588392-YmeaLWSLJcDqswQDL8sdqrnoBcbr0Ht7CSLYDiRmpg%2520%26oauth_version%3D1.0%26status%3Dtest
[Wed Jan 23 08:41:52 JST 2013]OAuth signature: ppnBeFh/FkC257KfuAseMUSz2yE=
[Wed Jan 23 08:41:52 JST 2013]Authorization: ***********************************************************************************************************************************************************************************************************************************************************************************
[Wed Jan 23 08:41:52 JST 2013]X-Twitter-Client-URL: http://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3).xml
[Wed Jan 23 08:41:52 JST 2013]X-Twitter-Client: Twitter4J
[Wed Jan 23 08:41:52 JST 2013]Accept-Encoding: gzip
[Wed Jan 23 08:41:52 JST 2013]User-Agent: twitter4j http://twitter4j.org/ /3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)
[Wed Jan 23 08:41:52 JST 2013]X-Twitter-Client-Version: 3.0.4-SNAPSHOT(build: 741de654255dfd4f0b154533bbb4fa76a88f6ab3)
[Wed Jan 23 08:41:52 JST 2013]Post Params: status=test&include_entities=1&include_rts=1
[Wed Jan 23 08:41:52 JST 2013]Response:
[Wed Jan 23 08:41:52 JST 2013]HTTP/1.1 400 Bad Request
[Wed Jan 23 08:41:52 JST 2013]Date: Tue, 22 Jan 2013 23:41:52 UTC
[Wed Jan 23 08:41:52 JST 2013]Content-Length: 86
[Wed Jan 23 08:41:52 JST 2013]Content-Encoding: gzip
[Wed Jan 23 08:41:52 JST 2013]Content-Type: application/json; charset=utf-8
[Wed Jan 23 08:41:52 JST 2013]Server: tfe
[Wed Jan 23 08:41:52 JST 2013]{"errors":[{"message":"Bad Authentication data","code":215}]}