I have a problem with cURL and magic_quotes.
for different reasons i cannot turn magic_quotes off. But i do need to disable this feature when I create a CURL POST request.
In this CURL POST request I pass a variable that contains XML and xml opening tag, something like this:
$xml_request = ' <?xml version="1.0"?><SaleRequest> <CustomerData> <Email>alex@virtuman.com</Email> <CustomerData> <SaleRequest>';
after I create a curl post request:
$url="https://my.secureserver.com/parsexmlscript.cgi";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "xml=".$xml_request);
curl_setopt ($ch, CURLOPT_HEADER, 0);
$result = curl_exec ($ch);
curl_close ($ch);
in the result: request received on the secure server - first opening tag looks like this:
<?xml version=\"1.0\"?>
(with version attribute is with magic quotes) after this xml parser dies telling me that XML document is not well formed.
is there any way to disable magic quotes for only one script that 开发者_StackOverflowcreates this post request ?
or may be there is any other way of getting around it ?
any help is greatly appreciated!!!
Why don't you use base64_encode( $xmldata )
and in perl base64_decode( $incomingdata )
?
This way php has no strange characters to encode.
Another way is to replace all quotes with 2 tildes like str_replace("'", "~~", $outgoingstring);
and on the incoming script you replace them back.
Possible steps:
- try
stripslashes($xml_request)
in your actual code - in 2003
set_magic_quotes_runtime(0)
might have helped - .htaccess
php_flag magic_quotes off
maybe wrapped in a<Files specific.php>
Most of that information is in the PHP manual about magic_quotes
Comments will not be answered.
Try this:
$xml_request = str_replace("\\", "", $result);
精彩评论