Twitter4J 4.1.0 released

Twitter4J is back with a major rework.

What’s new in 4.1.0?

  • Require Java 8+
    Java 7 has been EOL’ed. Java 17 is much more fun and productive to work with.
  • Compatible with Java Module System (Java 9+)
    You can just declare ‘require org.twitter4j’ in to add dependency to your module.
  • Immutable everywhere
    There is no setters which may cause undesirable behavior in multi-threaded environments. Use builder instead. You can find example codes at Twitter4J/twitter4j-examples/src/main/java/examples/.

What’s next?

Twitter API v2 support is coming.

Twitter4J 4.0.7 リリース

Twitter4J 4.0.7をthe Maven Central Repositoryにアップロードしました。



これはJava 6, 7をサポートする最後のリリースとなる予定です。

次期リリースからはJava 8以降が必要となります。

#Twitter4J 4.0.7-SNAPSHOT リリース – DMを利用するアプリは要移行



ダイレクトメッセージを扱うアプリケーションを引き続き稼働させるにはTwitter4J 4.0.7に移行してください。


ResponseList getDirectMessages()
ResponseList getDirectMessages(Paging paging)
ResponseList getSentDirectMessages()
ResponseList getSentDirectMessages(Paging paging)


4.1か5.0かわかりませんが今後のリリースでこれらの非推奨メソッドは削除されますので適宜DirectMessageList getDirectMessages(int count)を使うように書き換えてください。

またdestroyDirectMessage(long id)は全てのgetterがUnsupportedOperationExceptionをスローするダミーオブジェクトを返しますので注意してください。。新しいエンドポイントは戻り値がないためです。

releasing #Twitter4J 4.0.7-SNAPSHOT – Apps using DM need to migrate

Latest Twitter4J snapshot build is now available at our in-house repository.

Twitter is going to sunset good old DM endpoints on August 16th, 2018.

In order to keep your chatbot working properly, you’ll need to migrate to Twitter4J 4.0.7.
This version is compatible with previous version with a slight exception. Rebuilding your application is required.

Here you can see the full list of API changes between 4.0.6 and 4.0.7.

The following methods are now deprecated.
ResponseList getDirectMessages()
ResponseList getDirectMessages(Paging paging)
ResponseList getSentDirectMessages()
ResponseList getSentDirectMessages(Paging paging)

The above deprecated methods are now internally invoking the latest and greatest end points. This means, your application will be working correctly without any changes even after the massacre coming this week.

But they will be removed in the future release – 4.1.0, 5.0.0 or whatever.
Please migrate to DirectMessageList getDirectMessages(int count) in a timely manner.

Note that destroyDirectMessage(long id) returns an object with dummy getters which throw UnsupportedOperationException, because the new endpoint doesn’t return any value.

#Twitter4J 4.0.4 リリース – 長文DMサポート、Lambda表記サポートなど

Twitter4J 4.0.4をリリースしました。Maven central repositoryTwitter4J.orgのスナップショットリポジトリよりお使い頂けます。




Twitterは7月より140文字を超えるDMを送受信できるようになります。Twitter4J 4.0.4以降を使えばコードの変更なく長文DMを受け取るようになります。
twitter Removing the 140 character limit from Direct Messages


これは、Twitter4J固有のファンクショナルインターフェースを導入することで実現しており、Twitter4Jを引き続きJava6(Maven central repositoryバージョン)並びにJava5(twitter4j.orgバージョン)と互換性があります。


Twitter4Jは様々な箇所で可変長引数を受け取れるようになりました。スクリーン名や、フィルタリングの単語を指定するのに面倒なnew String[]{}を書く必要がなくなります。


SavedSearch idタイプの移行


#Twitter4J 4.0.4 released – supports longer DM texts, lambda expression and more

We have just release Twitter4J 4.0.4. The build is available at the Maven central repository and’s snapshot repository.


We have made some slight changes that could introduce binary compatibility, and it is encouraged to REBUILD your project when migrating to version 4.0.4.

Support for longer DM texts

Twitter will be allowing users to send and receive 140+ DMs in July. Projects using Twitter4J 4.0.4+ will receive longer DM text without any code change.
twitter Removing the 140 character limit from Direct Messages

Support for lambda expression

Twitter4J is finally lambda ready. You can implement streaming API’s listener actions in lambda expression using onStatus(Consumer) and onException(Consumer).
This is done by introducing Twitter4J specific functional interface, and Twitter4J will be continued to be compatible with Java 6+.

Support for variable arguments in many places

Twitter4J now accepts variable arguments in many places. It is no longer required to put new String[]{} when passing list of screen names, filtering terms.

Please take a few seconds to see how lambda and varargs will simplify Twitter4J’s client code:

SavedSearch id type migration

int is no more sufficient to handle SavedSearch’s id. The return type of SavedSearch#getId() is now long. Note that serialized objects of this class is not compatible with previous releases.