<< Previous | Home

Sakasa-Fuji in the sky

It is no doubt that Mt. Fuji is the most beautiful mountain in Japan. Therefore many photographers, and painters love Mt. Fuji.
There is a quite popular composition of the mountain which is called "逆さ富士"(Sakasa-Fuji) - meaning "inverted Fuji" in Japanese.
There are five lakes near Mt. Fuji and you can see inverted, or reflected image of the mountain on a water surface when you are walking beside one of those lakes.
- Google Image Search - Sakasa-fuji

On Jan 2nd, I took two phenomenal Sakasa-fuji pictures.


Mt. Fuji with its silhouette

In this picture, a projected outline of the mountain can be seen in the atmosphere.


Sakasa-Fuji in the sky

You can see an upside-down shadow of the mountain on the cloud.

How mystic it is!

Twitter4J 1.1.4 released

Twitter4J 1.1.4 is now available for download.
http://yusuke.homeip.net/twitter4j/en/index.html#download

Projects using getUserDetail() need to apply this version in order to avoid NPE with protected users(TFJ-70).
This version will also be available in the Maven central repository in 24 hours.
Here are the list of fixes included in version 1.1.4.
Recompilation of your project is suggested before you update your twitter4j jar file.

Bug

  • [TFJ-70] - getting a protected user profile causes a NullPointerException

Improvement

  • [TFJ-69] - some async methods are declared to throw TwitterException mistakenly

New Feature

  • [TFJ-48] - support update_delivery_device method
  • [TFJ-52] - support exists method
  • [TFJ-53] - support rate_limit_status method

Twitter4J 1.1.2 released

Twitter4J 1.1.2 has just been released and will be available from the maven central repository soon.

Twitter4J is an open-sourced and mavenizable Java library for the Twitter API which is released under a BSD-style license.
http://yusuke.homeip.net/twitter4j/index.html


With Twitter4J, you can easily integrate your application with twitter.com.

This release contains a couple of bug fixes for AsyncTwitter.
Users using AsyncTwitter may want to apply this apply this release.
Here are the list of fixes included in version 1.1.2.

Bug

  • [TFJ-61] - AsyncTwitter#createFavoriteAsync(), destoryStatusAsync(), destroyFavoriteAsync() should take long instead of int
  • [TFJ-64] - AsyncTwitter#show(long) fails with ClassCastException

Improvement

  • [TFJ-63] - typo: detroy -> destory

Twitter4J 1.1.1 released

Twitter4J 1.1.1 has just been released and will be available from the maven central repository soon.

Twitter4J is an open-sourced and mavenizable Java library for the Twitter API which is released under a BSD-style license.
http://yusuke.homeip.net/twitter4j/index.html


With Twitter4J, you can easily integrate your application with twitter.com.

This release contains several bug fixes and all users are strongly suggested to update.
Here are the list of fixes included in version 1.1.1.

Bug

  • [TFJ-54] - Show method should take long instead of int
  • [TFJ-55] - Show method shouldn't require userid and password
  • [TFJ-56] - TwitterResponse from AsyncTwitter is not Serializable
  • [TFJ-57] - Date is encoded twice, and therefore "since" doesn't work
  • [TFJ-60] - hashCode and equals are not properly implemented

Improvement

  • [TFJ-47] - implement toString()

releated:
- Post to Twitter using Java: Twitter4J - Richard’s World

Decoding the Mars Phoenix's last Tweet using Twitter4J on IntelliJ IDEA 8

Mars Phoenix had been Tweeting about everything she discovered on the red planet. On November 11th, she posted her last tweet in a cryptic binary form which ends with a heart emoticon. How romantic it is!

Some of those people who follow her tweets might be able to understand it natively, but my decimal based brain couldn't. So I decided to write down a tiny code that decodes it using the fresh, and yummy IntelliJ IDEA 8.

Here's the steps I followed.

1. Create a project
From the File menu, you can create a mavenized project very easily.
[File > New Project...]
[Create project from scratch > Next]


Project wizard

Name: marsphoenix
Select type: Maven Module

Projec wizard-2

Press [Next] to proceed.

You can choose an archetype at this point if you like.


Press [Finish] to finish the project wizard.

A mavenized project was created.

a typical mavenized empty project

2. Create a class
right-click marsphoenix/src/main/java node and choose [New > Class]


I named it DecodeLastTweet.

entering the class name

3. Using Twitter4J
I feel it's not interesting if I hard code the message as a String literal. So why don't we grab it using Twitter4J?

Twitter4J is super easy to use. You can just pass your userid and password to create a Twitter instance as follows:

    public static void main(String[] args){
Twitter twitter = new Twitter("userid","password");
}

Oops, Twitter doesn't resolve.

red alarming font

Of course the reason why Twitter cannot be resolved is because the class hasn't been imported and it's not even declared in the dependencies in the pom.xml. In such a case, all you have to do is just moving the cursor to the appealing part. Then you'll see a bulb, which indicates that IntelliJ is offering you to do something for you.

an eye-catching bulb

Click the bulb to see the options:

[IDEA] What do you want me to do?

The best choice should be "Add Maven Dependency".

Dependency selection dialog

Adding the dependency to the latest version of Twitter4J is as simple as just selecting it. Then IDEA will automagically add dependency declaration to the pom.xml, and import statement for twitter4j.Twitter class.


automatically managed pom.xml and import statement

Pretty smart.
Let's move on to next.

4. Getting the status
The status id of her last tweet is 999383469.
So the code to get it should be like this:
    Status status = twitter.show(999383469);


And of course, IDEA is smart enough to add the import statement for twitter4j.Status automatically. Since show method throws TwitterException, you are either to choose rethrowing the Exception, or enclose the method with a try - catch block.

To catch, or not to catch, that is the problem.

This isn't a serious code and I chose the latter one - "Add Exception(s) to Method Signature&qout; this time.

throws signature added

5. Finish the code!
Lastly, I added following steps:
- split the tweet with space
- decode each binary strings to int type
- cast them to char type
- print them

The complete code looks like this:
public class DecodeLastTweet {
public static void main(String[] args) throws TwitterException {
Twitter twitter = new Twitter("yourid", "password");
Status status = twitter.show(999383469);
String text = status.getText();
String[] split = text.split(" ");
for (String token : split) {
try {
System.out.print((char) Integer.parseInt(token, 2));
} catch (NumberFormatException ignore) {}
}
}
}



the complete code

6. Run it
You can run the class by just pressing the "Play" button.

IDEA is showing the decoded message

- Conclusion
I intentionally hidden the decoded message.
You can download the BSD licensed code, build it, and run it on your own box if you want.

I also hope you glanced how productive the latest IntelliJ IDEA is. As you know, IDEA is a commercial product.
It's not free, but life is short. Don't hesitate to invest on your productivity.
I believe that very soon after you bought the product, you'll reach the break-even point because of the super-productiveness.


just FYI: Jetbrains is also offering a free license for open source developers.

Related:
- Twitter4J 1.1.0 released - Samuraism
- decoding the Mars Phoenix's last Tweet using Python and python-twitter
- JetBrains IntelliJ IDEA Blog » Blog Archive » Meet JetBrains’ Release of the Year: IntelliJ IDEA 8
- IntelliJ IDEA, Why I like | Appliweb

Twitter4J 1.1.0 released

Twitter4J 1.1.0 has just been released and is available at the maven central repository.

Twitter4J is an open-sourced and mavenizable Java library for the Twitter API which is released under a BSD-style license.
http://yusuke.homeip.net/twitter4j/index.html


With Twitter4J, you can easily integrate your application with twitter.com.

Twitter4J 1.1.0 includes small bug fixes and its memory foot print has been dramatically improved.
Please take extra care upon migration since the release is slightly incompatible with prior versions.
So it is strongly recommended to recompile your application instead of just replacing the jar file.

Methods updated:
TFJ-41: Following methods now return long instead of int since the status id will reach Integer.MAX_VALUE(2147483647).

long Status.getId()
long UserWithStatus.getStatusId()
long getInReplyToStatusId()
TFJ-34: Following methods now return java.util.Date instead of String.
java.util.Date Status.getCreatedAt()
java.util.Date DirectMessage#getCreatedAt()

Methods added:
TFJ-45:
List<User> getFollowers(int page)
List<User> getFollowers(String id)
List<User> getFollowers(String id, int page)

Methods removed:
TFJ-43: Following methods are no longer supported by the Twitter API and removed as of release 1.1.0.
Twitter.getPublicTimeline(String sinceID)
Twitter.archive()
Twitter.archive(int page)


You can check the complete list of changes at the Twitter4J Jira site.
http://yusuke.homeip.net/jira/browse/TFJ/fixforversion/10100

releasing Twitter4J 1.0.6

I'm glad to announce the release of Twitter4J 1.0.6.
Twitter4J is an open-sourced and mavenized Java library for the Twitter API which is released under a BSD-style license.
http://yusuke.homeip.net/twitter4j/index.html

With Twitter4J, you can easily integrate your application with twitter.com.

Twitter4J 1.0.6 fixes some compatibility issues.
All projects depending on Twitter4J are strongly suggested to update the library.
You can check the complete list of changes at the Twitter4J Jira site.
http://yusuke.homeip.net/jira/secure/IssueNavigator.jspa?reset=true&pid;=10002&fixfor;=10090