android - 使用 twitter4j-4.0.1 在 android 中集成 Twitter

标签 android twitter oauth

我正在尝试将 twitter 集成到 android 中,我已按照以下链接中的教程进行操作 http://www.androidhive.info/2012/09/android-twitter-oauth-connect-tutorial/

但我在这些行的 loginwithTwitter 函数中遇到异常

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();
        }

我得到的 e.getMessage() 为 null 并且在这一行发生了异常

requestToken = twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);

请帮我解决这个问题。我还在互联网上搜索过,在 stackoverflow 上搜索过类似的查询,例如 Android twitter login not workingTwitter Login Authentication in Android? 所以请帮助我,我正在使用 twitter4j-4.0.1

最佳答案

我遇到了同样的问题。我引用了本教程并且它有效 - http://hintdesk.com/how-to-tweet-in-twitter-within-android-client/comment-page-1/

而且他们已经更新到 twitter4j-core-4.0.1

可在此处找到源代码 - https://bitbucket.org/hintdesk/android-how-to-tweet-in-twitter-within-android-client

关于android - 使用 twitter4j-4.0.1 在 android 中集成 Twitter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22543102/

相关文章:

oauth - 如何在 WebAPI 中使用 Google Analytics oAuth?

android - 我的应用程序在 Nexus 4 Lollipop 设备上不显示除黑色和白色之外的文本颜色

java - 3 Android Threads,如何构造

oauth - MVC4 Web API 的身份验证

ios - 我可以为 Twitter 和 Facebook 以外的社交网络创建或使用像 SLComposeViewController 这样的 View Controller 吗

c# - 带有 linq2twitter/tweetinvi 的 Twitter 流媒体 api

ruby-on-rails - shopify 应用程序授权陷入无限重定向

android - 为什么我的谷歌开发者控制台无法访问 API 和授权?

java - 我如何设置闹钟管理器在 android 中的每周特定日期和时间触发?

css - 未使用 Twitter Bootstrap 修复时居中导航栏内容?