Performing a GET request via cURL in PHP is causing me a few issue because cURL is formatting the response.
E.g.
//http://test.com?callback=mydomain.net;
curl_exec($ch);
Response (expected) {myJson : "text"}
Repsonse (actual) (mydomain.net({myJson : "text"});
It is prefixing the JSON response with anything that is specified in the callback query parameter, this means the response is not valid JSON. Our current work around is to strip off the preceding formatted name and the last bracket, but that is haxy as. We are calling an external web service and have no access to change the query parameter name.
Is there a way to turn this off?
How do we turn this off?
Config for my curl request:
curl_setopt( $this->_ch, CURLOPT_URL,$this->_uri);
curl_setopt( $this->_ch, CURLOPT_ENCODING, "" );
curl_setopt( $this->_ch, CURLOPT_CONNECTTIMEOUT, $this->_timeout );
curl_setopt( $this->_ch, CURLOPT_TIMEOUT, $this->_timeout );
curl_setopt( $this->_ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt( $this->_ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $this->_ch, CURLOPT_VERBOSE, true);
curl_setopt( $this->_ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt( $this->_ch, CURLOPT_SSL_VERIFYPEER, 0);