HTTP Post with xml Document
Posted: Mon Nov 08, 2010 12:36 am
HI All
I am very much new to PHP programmng. I am having requirement that I can call web API Through HTTP POST with with XML file.
I tried with
functions and getting errow like below
'Protocol https not supported or disabled in libcurl !!! '
is there any other methods to post xml ..
Please guide me .. Thanks in advance for your help
Satya
I am very much new to PHP programmng. I am having requirement that I can call web API Through HTTP POST with with XML file.
I tried with
Code: Select all
$url=" https://site.one.com";
$post_string='<requestEnvelope xmlns="http://services.xyz.com/infoset"> <header> <credentials> <userNameAndPassword> <name>satya</name> <password>xcvfder</password> </userNameAndPassword> </credentials> </header> <requests> <request tag="0:Network.GetSites()"> <service>network</service> <operation>getSites</operation> <arguments> <network id="1651410" /> </arguments> </request> </requests> </requestEnvelope>';
$header = 'POST HTTP/1.0 \r\n';
$header .= 'Content-type text/xml \r\n';
$header .= 'Content-length: ".strlen($post_string)." \r\n';
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $post_string;
curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $header);
$data = curl_exec($ch);
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
'Protocol https not supported or disabled in libcurl !!! '
is there any other methods to post xml ..
Please guide me .. Thanks in advance for your help
Satya