3

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

Community
  • 1
  • 1
user3313379
  • 459
  • 10
  • 21
  • follow this tutorial which allow user to post tweet and search from all publically available tweets http://tech-papers.org/integrate-twitter-with-android-application/ – Balwinder SIngh Oct 25 '14 at 16:37

2 Answers2

5

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

  • I'm a bit confuse about the callback url that is placed within the manifest data:host property. His host name is com.hintdesk.Twitter_oAuth however, twitter provides http://someapp.com for the callback url. What should I use in this instance – user2054833 Feb 02 '15 at 03:19
0

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.

Guy Smith
  • 178
  • 1
  • 12