我也遇到一样的问题,搞了好久都没解决,总是报错 ,出来个大侠拯救一下吧 please paste the url in your webbrowser, complete the authorization then come back: null net.oauth.OAuthProblemException at net.oauth.client.OAuthHttpClient.invoke(OAuthHttpClient.java:71) at net.oauth.client.OAuthClient.invoke(OAuthClient.java:96) at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:67) at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:82) at com.google.gdata.client.douban.DoubanService.getAuthorizationUrl(Unknown Source) at Demo.main(Demo.java:19)
真的没有人可以解决这个问题吗?静待“扫地神僧”。 测试代码如下: public class DoubanDemo { public static void main(String[] args) { String apiKey = "078ceaae662c2dce16a6c00b3284896a"; String secret = "68c9a5faa2192952"; DoubanService myService = new DoubanService("stephen的小豆瓣", apiKey, secret); System.out.println("please paste the url in your webbrowser, " + "complete the authorization then come back:"); System.out.println(myService.getAuthorizationUrl(null)); byte buffer[] = new byte[1]; try { System.in.read(buffer); } catch (IOException e) { e.printStackTrace(); } ArrayList<String> tokens=myService.getAccessToken(); System.out.println(tokens.get(0)); System.out.println(tokens.get(1));
} } 运行结果如下: please paste the url in your webbrowser, complete the authorization then come back: null net.oauth.OAuthProblemException at net.oauth.client.OAuthHttpClient.invoke(OAuthHttpClient.java:71) at net.oauth.client.OAuthClient.invoke(OAuthClient.java:96) at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:67) at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:82) at com.google.gdata.client.douban.DoubanService.getAuthorizationUrl(Unknown Source) at appdemo.DoubanDemo.main(DoubanDemo.java:43)
<uses-permission android:name="android.permission.INTERNET"/>
//叙述:这是一个oauth协议, 我现在想利用在豆瓣官网申请的apikey去豆瓣索要一个授权的网页。可是怎么都拿不到这个授权网页,代码和apikey已经反复检查好多变了。还有编码也改成UTF-8的了,(本以为可能gbk的不行)。奇怪的是我这段代码在其他人的电脑上就可以运行并能拿到 授权网页。但是在我的电脑上已运行就报下面这样的错误。到低是什么原因呢?原来以为是I…… 哥们,你的豆瓣帐号和密码是多少。私聊啊 急事找你帮忙
你仔细看它申请Key的流程~
please paste the url in your webbrowser, complete the authorization then come back:
null
net.oauth.OAuthProblemException
at net.oauth.client.OAuthHttpClient.invoke(OAuthHttpClient.java:71)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:96)
at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:67)
at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:82)
at com.google.gdata.client.douban.DoubanService.getAuthorizationUrl(Unknown Source)
at Demo.main(Demo.java:19)
测试代码如下:
public class DoubanDemo { public static void main(String[] args) {
String apiKey = "078ceaae662c2dce16a6c00b3284896a";
String secret = "68c9a5faa2192952"; DoubanService myService = new DoubanService("stephen的小豆瓣", apiKey,
secret); System.out.println("please paste the url in your webbrowser, "
+ "complete the authorization then come back:");
System.out.println(myService.getAuthorizationUrl(null));
byte buffer[] = new byte[1];
try {
System.in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
ArrayList<String> tokens=myService.getAccessToken();
System.out.println(tokens.get(0));
System.out.println(tokens.get(1));
}
}
运行结果如下:
please paste the url in your webbrowser, complete the authorization then come back:
null
net.oauth.OAuthProblemException
at net.oauth.client.OAuthHttpClient.invoke(OAuthHttpClient.java:71)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:96)
at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:67)
at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:82)
at com.google.gdata.client.douban.DoubanService.getAuthorizationUrl(Unknown Source)
at appdemo.DoubanDemo.main(DoubanDemo.java:43)