twitter4j的2.2.2版只是一个小小的改变。这样做有效:
Configuration configuration = new ConfigurationBuilder()
.setOAuthConsumerKey("your_customer_key")
.setOAuthConsumerSecret("your_customer_secret")
.build();
Twitter twitter = new TwitterFactory(configuration).getInstance(new BasicAuthorization(username, password)); // yes, use "BasicAuthorization" although that seems strange
AccessToken token = twitter.getOAuthAccessToken();
Log.d(TAG, "Access token: " + token.getToken());
Log.d(TAG, "Access token secret: " + token.getTokenSecret());
记住,您的twitter客户端应用程序需要
authorized to use xAuth
在这起作用之前。