I use twitter4j on my Android 1.6 phone to request user related data such as all new direct messages or follower ids. It works fine if I only request trends or other user unrelated information (trends for example) but if I try to query information such as the follower ids or new direct messages twitter4j throws an TwitterException with the following cause
java.io.FileNotFoundException: http://api.twitter.com/1/direct_messages.json
I create an instance of twitter with the following code:
TwitterFactory twitterFax = new TwitterFactory();
twitterInstance = twitterFax.getInstance(USERNAME, USER_PASSWORD);
The exception throws here:
try {
ResponseList<DirectMessage> directMessages = twitterInstance.getDirectMessages();
if(directMessages.size() > 0){
publishProgress(directMessages.toArray());
}
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Why does it not work?
The twitter API doesn't support simple authentication anymore (you also didn't verify them as well), use OAuth:
http://twitter4j.org/en/code-examples.html#oauth
Also see: Twitter4J exception on verifyCredentials