我正在嘗試以下示例應用程序的twitter oauth。android twitter retrieveRequestToken 401請求令牌
http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html
private void askOAuth() {
try {
consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
provider = new DefaultOAuthProvider("http://twitter.com/oauth/request_token",
"http://twitter.com/oauth/access_token",
"http://twitter.com/oauth/authorize");
String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show();
this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
} catch (Exception e) {
Log.e(APP, e.getMessage());
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
當我運行下面的代碼它提供了異常如下
「oauth.signpost.exception.OAuthNotAuthorizedException:授權失敗(服務器回答道401)這可能是因爲。消費者密鑰不正確或簽名不匹配。「
在這條線String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
我提供了正確的「鑰匙」和「祕密」不推特給了我錯了密鑰和密碼
?
plz告訴我要在CALLBACK_URL中放置什麼? – Shruti 2012-09-11 09:58:25
你的android活動URL會在twitter返回響應後被調用 – 2012-09-11 18:46:00
你的android活動URL會在twitter返回響應後被調用 – 2012-09-11 18:46:47