我使用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(); } }
谢谢.
解决方法
原文地址:https://www.jb51.cc/android/311041.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。