我尝试访问我的 Google+ 帐户以获取我的数据。现在,我找到了样本,但它不能正常工作......
见这里:
我的问题在第 70 行!
如果我在抛出异常后尝试运行该程序
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver.getRedirectUri(LocalServerReceiver.java:97)
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:71)
at com.google.api.services.samples.plus.cmdline.PlusSample.authorize(PlusSample.java:70)
at com.google.api.services.samples.plus.cmdline.PlusSample.main(PlusSample.java:77)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
现在我尝试了 google-plus-java-starter 项目。
我在控制台上注册,得到了我的 client_id 和 client_secret 以及我的 API 密钥,但现在抛出了一个异常。
Attempting to open a web browser to start the OAuth2 flow
Once you authorize please enter the code here: [entered myCode here]
============== Get my Google+ profile ==============
Okt 15, 2012 2:00:06 PM Sample getProfile
Schwerwiegend: {
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
Exception in thread "main" java.io.IOException: Stream closed
at java.util.zip.GZIPInputStream.ensureOpen(Unknown Source)
at java.util.zip.GZIPInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at com.google.api.client.http.HttpResponse.parseAsString(HttpResponse.java:464)
at Sample.main(Sample.java:45)