我正在尝试使用以下Twitter OAuth的示例应用程序。
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);
我提供了正确的“key”和“secret”,Twitter给错了我的密钥和秘密吗?