diff options
author | Vitaly Takmazov | 2022-10-13 04:51:43 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2022-10-13 04:51:43 +0300 |
commit | 60d6de1cbd4b04c1fe1dd5c8e549fa76ef2844bb (patch) | |
tree | 0cffbbda155849b8e156b6e55624aaa64c3a6ea6 | |
parent | 73dfe133a0341f7d40811bf21678eeba5ed868e9 (diff) |
Bump twitter4j to 4.1.0, fix compatibility with API changes
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | src/main/java/com/juick/TwitterManager.java | 15 |
2 files changed, 6 insertions, 11 deletions
@@ -232,7 +232,7 @@ <dependency> <groupId>org.twitter4j</groupId> <artifactId>twitter4j-core</artifactId> - <version>4.0.7</version> + <version>4.1.0</version> </dependency> <dependency> <groupId>com.rometools</groupId> diff --git a/src/main/java/com/juick/TwitterManager.java b/src/main/java/com/juick/TwitterManager.java index 8af672a3..a6a53e6c 100644 --- a/src/main/java/com/juick/TwitterManager.java +++ b/src/main/java/com/juick/TwitterManager.java @@ -27,8 +27,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import twitter4j.TwitterFactory; -import twitter4j.conf.ConfigurationBuilder; +import twitter4j.Twitter; import javax.inject.Inject; @@ -54,15 +53,11 @@ public class TwitterManager implements NotificationListener { status = status.substring(0, 252) + "…"; } status += " http://juick.com/" + jmsg.getMid(); - ConfigurationBuilder configurationBuilder = new ConfigurationBuilder() - .setDebugEnabled(true) - .setOAuthConsumerKey(twitter_consumer_key) - .setOAuthConsumerSecret(twitter_consumer_secret); - TwitterFactory tf = new TwitterFactory(configurationBuilder - .setOAuthAccessToken(t.getToken()) - .setOAuthAccessTokenSecret(t.getSecret()).build()); + var twitter = Twitter.newBuilder() + .oAuthConsumer(twitter_consumer_key, twitter_consumer_secret) + .oAuthAccessToken(t.getToken(), t.getSecret()).build(); try { - tf.getInstance().updateStatus(status); + twitter.v1().tweets().updateStatus(status); } catch (Exception e) { logger.info("Twitter exception {}: {}", jmsg.getUser().getName(), e); } |