Last active
December 23, 2015 17:29
-
-
Save mdeverdelhan/6668777 to your computer and use it in GitHub Desktop.
Posting a tweet using Twitter4J.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.twitter4j</groupId> | |
<artifactId>twitter4j-core</artifactId> | |
<version>3.0.3</version> | |
</dependency> | |
<!-- ... --> | |
</dependencies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
400:The request was invalid. An accompanying error message will explain why. This is the status code will be returned during version 1.0 rate limiting(https://dev.twitter.com/pages/rate-limiting). In API v1.1, a request without authentication is considered invalid and you will get this response. | |
message - Bad Authentication data | |
code - 215 | |
Relevant discussions can be found on the Internet at: | |
http://www.google.co.jp/search?q=b2b52c28 or | |
http://www.google.co.jp/search?q=10981ab8 | |
TwitterException{exceptionCode=[b2b52c28-10981ab8], statusCode=400, message=Bad Authentication data, code=215, retryAfter=-1, rateLimitStatus=null, version=3.0.3} | |
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177) | |
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61) | |
at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:98) | |
at twitter4j.TwitterImpl.post(TwitterImpl.java:1871) | |
at twitter4j.TwitterImpl.updateStatus(TwitterImpl.java:241) | |
at twitter.TwitterAPI.postExchangeRate(TwitterAPI.java:16) | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync. | |
message - Could not authenticate you | |
code - 32 | |
Relevant discussions can be found on the Internet at: | |
http://www.google.co.jp/search?q=b2b52c28 or | |
http://www.google.co.jp/search?q=10981ab8 | |
TwitterException{exceptionCode=[b2b52c28-10981ab8], statusCode=401, message=Could not authenticate you, code=32, retryAfter=-1, rateLimitStatus=null, version=3.0.3} | |
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177) | |
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61) | |
at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:98) | |
at twitter4j.TwitterImpl.post(TwitterImpl.java:1871) | |
at twitter4j.TwitterImpl.updateStatus(TwitterImpl.java:241) | |
at twitter.TwitterAPI.postExchangeRate(TwitterAPI.java:16) | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync. | |
{"request":"\/1.1\/statuses\/update.json","error":"Read-only application cannot POST"} | |
Relevant discussions can be found on the Internet at: | |
http://www.google.co.jp/search?q=b2b52c28 or | |
http://www.google.co.jp/search?q=10981ab8 | |
TwitterException{exceptionCode=[b2b52c28-10981ab8], statusCode=401, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.3} | |
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177) | |
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61) | |
at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:98) | |
at twitter4j.TwitterImpl.post(TwitterImpl.java:1871) | |
at twitter4j.TwitterImpl.updateStatus(TwitterImpl.java:241) | |
at twitter.TwitterAPI.postExchangeRate(TwitterAPI.java:16) | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debug=true | |
oauth.consumerKey=ZeWTr73DdFEj5w4gjzdw | |
oauth.consumerSecret=NgxpXhvGr887RLYb705OzwKbpyBx23FsDNF5FnD0 | |
oauth.accessToken=472356387-ireq8dXHKr08018nhqSb0Vp3gVI77UD4r3mLGSXb | |
oauth.accessTokenSecret=blUsP2dIdfjLyiDSk65fxV6qCqJaDU3TdTrQ2W4qjYG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Twitter twitter = TwitterFactory.getSingleton(); | |
try { | |
Status status = twitter.updateStatus("A tweet from twitter4j. #test"); | |
System.out.println("Successfully updated the status to [" + status.getText() + "]."); | |
} catch (TwitterException te) { | |
te.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment