0

Anyone knows how can I use twitter directly whitout asking for credential and not using OAuth library?

I want to put the credentials directly in the code and authorize the app, and then just see the home timeline.

I tried using jTwitter library but when I use the method getHomeTimeline it throws the error "Bad request".

Here is my code example:

try {

    winterwell.jtwitter.Twitter tw = new winterwell.jtwitter.Twitter("UserName","Password");
    List<winterwell.jtwitter.Twitter.Status> ls = tw.getHomeTimeline();

    for (winterwell.jtwitter.Twitter.Status status : ls) {
         System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
    }

} 

catch (TwitterException e) {
    e.printStackTrace();
    System.out.println("Failed to get timeline: " + e.getMessage());
}

Thanks in advance!

JoseLion
  • 105
  • 2
  • 7

1 Answers1

0

You can do this but it is not quite convinient. It will always retrieve the home timeline of the same user (the one that get its tokens written directly in the code). So you will have to compile one distinct application for each user of your app because the OAuth token and the OAuth secret will be different for each user. If you are the only user of the app, there won't be any problem but if other users will use it, it won't be convinient

However, you won't avoid the authentication process to get the user's tokens.

air-dex
  • 4,130
  • 2
  • 25
  • 25