I am working on the Twitter Authentication
. The Basic Authentication will expire on August 16th onwards. So we have to use OAuth
to use Twitter Authent
EDIT: In my code I did this:
System.setProperty("twitter4j.oauth.consumerKey", "your token");
System.setProperty("twitter4j.oauth.consumerSecret", "your token secret");
Twitter twitter = new TwitterFactory().getInstance(login, password);
AccessToken accessToken = twitter.getOAuthAccessToken();
Then you must save your Token and Token secret from AccesToken
if (mAccessToken != null) {
if (mAccessToken.getToken() != null && mAccessToken.getTokenSecret() != null) {
saveAccessToken(mAccessToken.getToken(), mAccessToken.getTokenSecret());
}
}
When you want to use your Token you just do this:
TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);