wget -d --header="Content-Type:application/xml" --post-data="$(cat <your xml file>)" http://sample.sample.com/api
How do i use this function in php? I want also to get the response from this function. i have a variable in php the viable is like this
$xml = '<sample>
<Request target="test">
</Request>
</sample>'
This is the xml that i want to post.
I tried the following:
$url = 'sample.sample.com/api';;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$(cat <".$xml.">)"); // receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $server_output = curl_exec ($ch);
curl_close ($ch);
But it returned this error:
Parsing XML failed: Start tag expected, '<' not found