在我的应用程序中,我想实现“通过 Twitter 分享”功能,用户将登录到 Twitter(如果尚未登录),然后可以分享他们的推文。使用我从互联网上获得的以下代码,我可以从我的应用程序中发布一条推文,但它从不要求登录。相反,它向我创建消费者密钥和秘密密钥的帐户发布了一条推文。
谁能指导我哪里出错了?
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setOAuthConsumerKey(twitter_consumer_key);
configurationBuilder.setOAuthConsumerSecret(twitter_secret_key);
String CALLBACK_URI = "http://www.google.com";
String ACCESS_TOKEN = "***************";
String ACCESS_TOKEN_SECRET = "****************";
AccessToken ac = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
Log.d("robin", "caught");
// Configuration configuration = configurationBuilder.build();
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(twitter_consumer_key, twitter_secret_key);
twitter.setOAuthAccessToken(ac);
Log.d("sayfsdem", "caught");
try {
twitter4j.Status status = twitter.updateStatus(tweetText);
Log.d("status", status.toString());
} catch (TwitterException e) {
// TODO Auto-generated catch block
Log.d("final", "caught");
e.printStackTrace();
}
try {
Log.d("userName", twitter.getScreenName());
// Log.d("password",twitter.getFavorites()());
} catch (IllegalStateException e) {
Log.d("illesayem", "caught");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TwitterException e) {
Log.d("fdfds", "caught");
// TODO Auto-generated catch block
e.printStackTrace();
}