Invalid JSON When Callback Specified

Hi,

In October I wrote a script to retrieve results from runtest.php. I specified the format JSON and told it to use a callback URL, and it worked fine. I just tried it and no longer works, though I’m not sure when/where the change occurred.

Rather than returning an object in JSON, runtest.php now returns the object in JSON but as if passed into a function: callback(object).

This form of URL:

http://www.webpagetest.org/runtest.php?private=1&f=json&callback=http://example.com/__callback&location=Dulles_IE8.DSL&k=***&url=google.com

Returns this form of response:

http://example.com/__callback({"statusCode":200,"statusText":"Ok","data":{"testId":"***","ownerKey":"***","jsonUrl":"http:\/\/www.webpagetest.org\/results.php?test=***&f=json","xmlUrl":"http:\/\/www.webpagetest.org\/xmlResult\/***\/","userUrl":"http:\/\/www.webpagetest.org\/result\/***\/","summaryCSV":"http:\/\/www.webpagetest.org\/result\/***\/page_data.csv","detailCSV":"http:\/\/www.webpagetest.org\/result\/***\/requests.csv"}});

It used to return just the object:

{"statusCode":200,"statusText":"Ok","data":{"testId":"***","ownerKey":"***","jsonUrl":"http:\/\/www.webpagetest.org\/results.php?test=***&f=json","xmlUrl":"http:\/\/www.webpagetest.org\/xmlResult\/***\/","userUrl":"http:\/\/www.webpagetest.org\/result\/***\/","summaryCSV":"http:\/\/www.webpagetest.org\/result\/***\/page_data.csv","detailCSV":"http:\/\/www.webpagetest.org\/result\/***\/requests.csv"}};

Is this new behavior expected? Thanks.

Argh, sorry. Most of the code suported JSON and JSONP where JSONP would be used if a callback parameter was specified. I was cleaning up the JSON support across the different API’s and didn’t catch the parameter collision.

Since “callback” is used pretty heavily for JSONP (and particularly for HAR’s and the har viewer) would you mind using “pingback” instead of “callback” for the URL? I just pushed the code to production and it should resolve the issue.