public static void main(String ... args) throws TwitterException, IOException {
String consumerKey = "Di1ZjpaZBqBTuCNBMmQ0g";
String consumerSecret = "Qsa832hZ0z6Di2AY1umfhAgPowf2YtjCxQvooRzXTM";
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(consumerKey,consumerSecret);
RequestToken requestToken = twitter.getOAuthRequestToken();
AccessToken accessToken = null;
p("go to this url: " + requestToken.getAuthorizationURL());
p("then press enter");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String pin = br.readLine();
if(pin.length() > 0){
accessToken = twitter.getOAuthAccessToken(requestToken, pin);
} else {
accessToken = twitter.getOAuthAccessToken();
}
p("got the access token: " + accessToken);
storeAccessToken(twitter.verifyCredentials().getId() , accessToken);
AccessToken toke = new AccessToken(accessToken.getToken(), accessToken.getTokenSecret());
twitter.setOAuthAccessToken(accessToken);
Status status = twitter.updateStatus("quick test of twitter with oauth. hope this works! :)");
p("changed the status to : " + status.getText());
}