$returnurl = "http://clietsite.com:9000/service";
$curlPost = "rtyinstance=<parent><child>value</child></parent>";
$ch1 = curl_init();
if (!$ch1) die("Couldn't initialize a cURL handle");
$headerinfo = apache_request_headers();
curl_setopt($ch1, CURLOPT_URL, $returnurl);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_POST, true);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($ch1, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch1, CURLOPT_USERAGENT, $headerinfo['User-Agent']);
curl_setopt($ch1, CURLOPT_TIMEOUT,1*60);
$result = curl_exec($ch1);
var_dump($result);
echo $responseCode = curl_getinfo($ch1, CURLINFO_HTTP_CODE);
curl_close($ch1);
The above code returns responseCode 200, var dump prints string(0) “”.
when i run in browser (I’m using PHP Version 5.2.17)
like
http://clietsite.com:9000/service?instance=<parent><child>value</child></parent>
Which successfully returns an xml. don’t know what could be the issue. Please help me solve this.
Via cURL you are using POST, while in the browser you issue a GET.
That might be the issue.
To ‘convert’ to GET, use this code: