【发布时间】:2012-01-22 00:27:26
【问题描述】:
我正在使用 twitter4j 从我的应用程序发送推文。当我调用方法 retrieveRequestToken 时,我收到错误“与服务提供者的通信失败:null”。
public static void askOAuth(Context context) {
try {
// Use Apache HttpClient for HTTP messaging
consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
provider = new CommonsHttpOAuthProvider(
"https://api.twitter.com/oauth/request_token",
"https://api.twitter.com/oauth/access_token",
"https://api.twitter.com/oauth/authorize");
String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
Toast.makeText(context, "Authorize this app!", Toast.LENGTH_LONG).show();
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
} catch (Exception e) {
Log.e(APP, e.getMessage());
Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
谢谢。
【问题讨论】: