问题
I am try to integrate twitter in android I have followed tutorial from following link http://www.androidhive.info/2012/09/android-twitter-oauth-connect-tutorial/
But I am facing an exception in loginwithTwitter function at these lines
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
Configuration configuration = builder.build();
TwitterFactory factory = new TwitterFactory(configuration);
twitter = factory.getInstance();
try {
requestToken = twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);
this.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(requestToken.getAuthenticationURL())));
} catch (TwitterException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
I got e.getMessage() as null and exception occures at this line
requestToken = twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);
Please help me solve this problem. I have also searched on internet and others queries like this on stackoverflow like Android twitter login not working and Twitter Login Authentication in Android? So kindly help me I am using twitter4j-4.0.1
回答1:
I was having the same problem. I referred to this tutorial and it works - http://hintdesk.com/how-to-tweet-in-twitter-within-android-client/comment-page-1/
and also they have updated to twitter4j-core-4.0.1
Source code can be found here - https://bitbucket.org/hintdesk/android-how-to-tweet-in-twitter-within-android-client
回答2:
Example code is at "https://github.com/gingerdroids/TwitterLogin".
I had difficulty getting Twitter login with Android and twitter4j going. Finally got there and uploaded a small sample app TwitterLogin to GitHub.
来源:https://stackoverflow.com/questions/22543102/twitter-integration-in-android-using-twitter4j-4-0-1