Created
March 8, 2012 10:08
-
-
Save jnaskali/2000102 to your computer and use it in GitHub Desktop.
PHP: Send XML over POST with cURL and save response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendXmlOverPost($url, $xml) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
// For xml, change the content-type. | |
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ask for results to be returned | |
// Send to remote and return data to caller. | |
$result = curl_exec($ch); | |
curl_close($ch); | |
return $result; | |
} |
I'm getting an "Array to string conversion" error for line 9. I'm sure it's a good xml file though.
What can I do to debug this?
Thanks for any help.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i tried to send xml request within curl return this response
notice : response must be xml
any help please