Current time: 12-19-2017, 04:38 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling webpagetest.org REST API from some other domain
05-23-2013, 02:35 PM
Post: #1
Calling webpagetest.org REST API from some other domain
Hi,

We are developing an internal tool which would give few other information apart from performance view of the webpage. For the performance part I would like to use some of the information provided by the webpagetest.org REST API. This is not a commercial tool.
And we already got the API key after sending a mail to You.

The problem comes when I am trying to call the API from some other domain.

My question here is : Is this API can be called from some other domain or Is it restricted from cross-domain calls because this has to be configured on the server itself?

For example : I want to call the API[http://www.webpagetest.org/runtest.php] from mydomain.org by making an AJAX call[along with the API key and some additional parameters] and expecting the webpagetest server to send me some xml as response which I will render in my customized UI. Is it possible?

Because when I am trying to do so, the call is getting cancelled in chrome and in firefox, it's prompting that - Redirecting to another page- but nothing happens even though I press Yes.

I know about the private instance of webpagetest but that will not solve my problem as I just want the xml response to integrate this with my application.

Please help.

Thanks in advance
Find all posts by this user
Quote this message in a reply
05-23-2013, 10:20 PM
Post: #2
RE: Calling webpagetest.org REST API from some other domain
You can't make cross-domain AJAX calls from within a browser page - period. You either need to send the calls to your server and then make the API calls from there or use JSONP for the cross-domain calls.

For JSONP to work you need to use the JSON version of the API (&f=json) and also pass a callback function. Then you add a script tag to your page (using javascript) with the src pointing to the runtest API with the json and callback. The specified callback will get called when the API call completes with the data passed as a parameter.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)