API OAuth验证
部署好Jtweet之后,在浏览器中输入地址http(s)://your-appid.appspot.com/api
在出现的页面上,根据自己的情况选择登录方式
- OAuth登录:需要登录
- OAuth Proxy登录:验证过程中需要twitter的ID和密码,存在安全隐患
如果是自己部署的应用的话,推荐使用OAuth Proxy方式,第三方的请自己判断
OAuth Proxy过程中的登录并验证
验证成功后,会自动生成密码,这时,你在客户端设置好API后,可以直接用twitter ID加此密码登录。如果你后悔的话,可以直接删除验证信息
如果生成的密码比较难记的话,可以在输入新密码后,点击修改按钮进行修改,修改成功后,会显示新的登录信息
至此,你可以用API——http(s)://your-appid.appspot.com/api,twitter ID和你最终获得的密码登录
我下载了jtweet_r239.zip,使用eclipse部署进GAE后,能访问到欢迎页面,选择OAuth proxy后返回空页面。页面就是个空body,啥也没有。有没有谁遇到这种问题?若有,解决方案如何?
我測試r232 r239 訪問API頁面 都 沒有 OAuth登陆 OAuth Proxy登陆 這兩個選項呢
只有如下的顯示 Jtweet,Twitter API proxy in Java on GAE. This is a Twitter API proxy,and is not intend to be viewed in a browser. Please use https://(這個就不顯示了吧?).appspot.com/api as a Twitter API URI in your Twitter Client.
后台日志贴出来看看
有日志倒好定位了,问题就是没日志,error和warn级的都没有。info的倒打了些日志,但是也是正常提示:This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
看了下代码,原因大概是getURLFetchService取回来的页面内容为空或者只是error的提示,程序并未对此做处理。 是每次都出现呢,还是偶尔出现?
反正我这里是每次出现。我估计是twitter API的问题,可能是请求到达API后,没有得到正确响应。
我的也是如此,一直都是空白,gae上也没有发现error或fatal之类日志。
API OAuth Proxy后返回时出现500错误 log err: /apicallback org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException??: The class "The class "jtweet.apiproxy.ApiUser??" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found." is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data for the class is not found.
而实际上ApiUser??这个类是存在的。
空body 重设twitter api中的Application Type:选Browser
r256版本api部分有错误,缺少accessToken = getToken(username);导致下面错误
09:48:49.903 Uncaught exception from servlet java.lang.NullPointerException?? at jtweet.apiproxy.ApiServlet??.generateAuthorizationHeader(ApiServlet??.java:197) at jtw
按照232版本改回去就没问题了