我使用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();
}
}
谢谢.