【问题标题】:How to receive twitter oauth token?如何接收 twitter oauth 令牌?
【发布时间】:2013-12-27 19:23:35
【问题描述】:

请求 OAuth(点击 twitter 按钮时)

final String TW_CALLBACK_URL_STRING = "http://test.com/callback";

final Uri TW_CALLBACK_URI = Uri.parse(TW_CALLBACK_URL_STRING);

twitter4j.auth.RequestToken twRequestToken = 
                        twitter.getOAuthRequestToken(TW_CALLBACK_URI.toString());

Intent intent = new Intent(Intent.ACTION_VIEW, 
                        Uri.parse(twRequestToken.getAuthorizationURL()));
activity.startActivityForResult(intent, TWITTER_REQUEST_CODE);

清单

    <activity android:name=".TwitterLinkActivity" >
        <intent-filter>            
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <data
                android:scheme="http"
                android:host="test.com" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </activity>

Twitter 开发者应用设置


点击我的应用程序上的 twitter 按钮,打开 Web 浏览器(chrome android)。

然后我登录 Twitter 帐户并单击“接受应用程序”按钮(下图中的“애플리케이션 승인”,UZTest 是我的测试 Twitter 应用程序名称。) 我不是以英语为母语的人。所以我不知道确切的英语单词......

我认为浏览器链接到http://test.com/callback?~~~~。我的应用程序捕获了这个 url,并开始活动。

但我的应用程序不能...它只是在 chrome android 浏览器中链接 http://www.test.com

我尝试更改回调 url = "myapp://test.com",但只有 http(或 https)可用。 (推特开发者)

如何接收 oauth 令牌?

【问题讨论】:

    标签: android twitter android-manifest twitter-oauth


    【解决方案1】:

    我确实解决了!

    以下两个值不是相同的值(?)

    1. 最终字符串 TW_CALLBACK_URL_STRING = "http://test.com/callback";

    2. 回调 URL:http://test.com/callback(Twitter 开发者中的 OAuth 设置)

    1 只使用我的应用程序。所以我在java代码和清单文件中改为“myscheme://myhost”。

    2 不是 oauth 请求回调 url(我不知道具体是什么。)

    然后它就可以正常工作了。

    【讨论】:

      猜你喜欢
      • 2012-12-21
      • 2012-06-22
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 2013-03-16
      • 2011-09-05
      • 2017-01-10
      • 1970-01-01
      相关资源
      最近更新 更多