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

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




Twitterは7月より140文字を超えるDMを送受信できるようになります。Twitter4J 4.0.4以降を使えばコードの変更なく長文DMを受け取るようになります。
twitter community.com: 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 Twitter4J.org’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 community.com: 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.

Harder, Better, Faster, Stronger version of Twitter4J – 4.0.0 is now available

Please welcome Twitter4J 4.0.0.

This is a must upgrade for everyone to get ready for the forth #twitterapocalypse.
The history of Twitter API is about bit length. In the past years, tweet IDs, DM IDs, and user IDs have migrated from 32 bit integer to 64 bit integer – followed by list IDs.
List IDs to become 64-bit integers in early 2014 | Twitter Blogs

With this release, list IDs (UserList IDs in Twitter4J terminology) become long. What you need to is just drop the latest jar and rebuild your project. In most cases, your application should work as before.

Be careful if you’re storing tweets, users, lists or any objects in a persistent store. List IDs need to be mapped to 64 bit or larger integer type. And serialized form of objects are NOT compatible with previous versions.

Release notes
Maven Central Repository
API difference between 3.0.6 and 4.0.0

There are more epic stories to be covered with this release. But first thing comes first, please migrate.

And our work is never over.

Twitter4J now supports application-only authentication

Finally application only authentication has come. Many thanks to @komiya_atsushi!

Application only authentication is an OAuth 2.0 based technique to make API calls without getting users’ permission. To enable application only authentication, you need to explicitly set enableApplicationOnlyAuth=true in your twitter4j.properties.

For more information, check dev.twitter.com and the test case.
Application-only authentication | Twitter Developers
twitter4j/twitter4j-core/src/test/java/twitter4j/auth/ApplicationOnlyAuthTest.java at master · yusuke/twitter4j · GitHub

Application-only authentication is currently available only with the latest snapshot build.

Still want to celebrate #Twitter4J6thAnniversary? Please consider making donation.
Celebrating​ #Twitter4J6thAnniversary | Twitter4J blog

Thanks, and happy tweeting!

Celebrating​ #Twitter4J6thAnniversary

Can’t believe that six years have past. It’s a long story!
I released the very initial version of Twitter4J on June 7th, 2007. I got one boy(@ryunosukey) and one girl(@babyyamamoto) since then.
Here are their first tweets.

I have no idea how many applications are using Twitter4J. But surely hundreds and thousands of applications are using it. I greatly appreciate all your help. Many many changes have been made to the Twitter API including introduction of rate limitation, image upload, hashtag, retweet, annotation, list, streaming API, API 1.1 and such. Me and contributors have been working very hard to catch up with the API without breaking stride. Just like my son and daughter, Twitter4J have been beloved by many developers. I’m very proud that Twitter4J have been, and will be supporting a large number of applications / services.
This could never happen without you – Twitter4J contributors and developers using Twitter4J.

Another interesting side of Twitter4J is that the success of Twitter4J lead yet other success stories. Dealing with Web API is not a rocket science. Actually Twitter4J is a super simple library. But making thing simple is sometimes even complex. I spent huge time on designing it’s interface and architecture. And now I see many libraries based on Twitter4J out there.
weibo4j – Sina Mblog openAPI javaSDK – Google Project Hosting
API Java Client – API – Confluence
Facebook4J – A Java library for the Facebook Graph API
ts-3156/mixi4j · GitHub

Again, many thanks to Twitter4J users and contributors. Ah, you want to say thanks to me? Hit the following tweet button and/or donate via PayPal!

If you like to, send an email to yusue@mac.com with your name, your service/application name, and URL. I’ll put a link below:

Twitter4J 2.x.x is dead, long live the Twitter4J 3.0!

I hope that you are aware of the Twitter API 1.0 retirement.

With this retirement, Twitter4J 2.2.x or earlier will no longer work ever again.

But you’re lucky!
Migrating to Twitter4J 3.0 (compatible with Twitter API 1.1) is super easy. Just move on to Twitter4J 3.0.x and you’ll see compile errors where you have any compatibility issue with the API 1.1.
If you don’t get it, have a look at the migration guide.
Twitter4J – Migrating from 2.2.x to 3.0.x