Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RetrieverRequestToken(CommonHttpOAuthConsumer,CALLBACK_URI)函数抛出OAuthCommunicationException_Android_Twitter_Oauth_Twitter Oauth - Fatal编程技术网

Android RetrieverRequestToken(CommonHttpOAuthConsumer,CALLBACK_URI)函数抛出OAuthCommunicationException

Android RetrieverRequestToken(CommonHttpOAuthConsumer,CALLBACK_URI)函数抛出OAuthCommunicationException,android,twitter,oauth,twitter-oauth,Android,Twitter,Oauth,Twitter Oauth,我想制作一个android应用程序,它将在twitter上更新状态。 我正在使用signpost-core-1.2.1.1和signpost-CommonHttp4-1.2.1.1 jar文件。我已授予互联网使用权限,并已在twitter上注册应用程序,授予读、写和直接消息权限。还填写了回调Url 代码段: private static final String CALLBACK_URI = "app://twitter"; private static final String REQU

我想制作一个android应用程序,它将在twitter上更新状态。 我正在使用signpost-core-1.2.1.1和signpost-CommonHttp4-1.2.1.1 jar文件。我已授予互联网使用权限,并已在twitter上注册应用程序,授予读、写和直接消息权限。还填写了回调Url

代码段:

private  static  final  String CALLBACK_URI = "app://twitter";
private static final String REQUEST_TOKEN_URL = "https://api.twitter.com/oauth/request_token";
private static final String ACCESS_TOKEN_URL = "https://api.twitter.com/oauth/access_token";
private static final String AUTHORIZE_URL = "https://api.twitter.com/oauth/authorize";

String CONSUMER_KEY = "XXXXXXXXXX";
String CONSUMER_SECRET = "XXXXXXXXXX";

private static  CommonsHttpOAuthConsumer consumer;
private static CommonsHttpOAuthProvider provider;

consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
provider = new DefaultOAuthProvider(REQUEST_TOKEN_URL,ACCESS_TOKEN_URL, AUTHORIZE_URL);
String authUrl="";

authUrl = provider.retrieveRequestToken(consumer,CALLBACK_URI);

我完全被这个问题困扰了。请回复。

首先,android应用程序不允许我们发送callbackurl,所以请使用“oob”而不是callbackurl,并且android上也支持twitter的api,这是jTwitter。

路标文档说DefaultOAuthProvider在java.net的Android实现中存在一些问题。他们建议改用CommonHttpOAuthProvider。我也有同样的问题。这就解决了我的这个例外。希望这能有所帮助。

jTwitter不再受twitter支持。他们已经改变了两个月前我在Android上使用jTwitter的权限模式。因此,没有限制。