1

OBJECTIVE:

I'm using GWT and trying to call an existing Twitter REST Service using RestyGWT client

PROBLEM:

I am not receiving a response to my GET request to "https://api.twitter.com/1.1/statuses/mentions_timeline.json"

THINGS I'VE TRIED:

I've looked at RestyGWT's documentation, and I couldn't come across a concrete example on how to call third party REST services. Tried calling a REST service using plaintext return types, same problem. There must be something I'm doing wrong on a fundamental leve.

CODE:

Here's my 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() );
                    }
            });
}

OUTPUT:

GWT MODULE LOADED
Twitter response:   NO
Exception:          org.fusesource.restygwt.client.FailedStatusCodeException: 
Exception Message:  
Status code:        0
4

2 回答 2

0

如果您正在访问不属于您的远程服务,您通常必须发送 JSONP 请求以解决相同的源策略。所以尝试r.jsonp()代替r.get().

于 2013-10-05T06:00:38.620 回答
0

jsonp 至少调用服务方法,但状态码为 0 的异常。但是 get 甚至没有到达服务方法。

于 2013-12-28T22:48:59.840 回答