转发:
客观的:
我正在使用 GWT 并尝试使用 RestyGWT 客户端调用现有的 Twitter REST 服务
问题:
我没有收到对“ https://api.twitter.com/1.1/statuses/mentions_timeline.json ”或其他 json 的 GET 请求的响应。
我尝试过的事情:
我查看了 RestyGWT 的文档,但没有找到关于如何调用第三方 REST 服务的具体示例。尝试使用纯文本返回类型调用 REST 服务,同样的问题。从根本上说,我一定是做错了什么。
代码:
这是我的 onModuleLoad:
public void onModuleLoad() {
Resource r = new Resource("https://api.twitter.com/1.1/statuses/mentions_timeline.json");
r.get().send(new JsonCallback() {
@Override
public void onSuccess(Method method, JSONValue response) {
System.out.println("Twitter response:\tYES");
}
@Override
public void onFailure(Method method, Throwable exception) {
System.out.println("Twitter response:\tNO");
System.out.println("Exception:\t\t"+exception.toString());
System.out.println("Exception Message:\t"+exception.getMessage());
System.out.println("Status code:\t\t"+method.getResponse().getStatusCode() );
}
});}
输出:
GWT MODULE LOADED
Twitter response: NO
Exception: org.fusesource.restygwt.client.FailedStatusCodeException:
Exception Message:
Status code: 0