开发者

php curl adding slashes to xml attributes

开发者 https://www.devze.com 2023-01-14 05:05 出处:网络
trying to post some xml with curl but it keeps adding slashes to \"s. 开发者_开发知识库I\'m sending it to a server i don\'t hav access so cant encode/decode...

trying to post some xml with curl but it keeps adding slashes to "s.

开发者_开发知识库

I'm sending it to a server i don't hav access so cant encode/decode...

$xmlToPost = '<PurchaseItems DISCOUNT="0" NETLINEVAL="0" PACK_CODE="0" VAT="0" PurchaseOrderNumber="'.$_POST['txn_id'].'">'; // just a snippet!

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://193.128.105.227/sukishufu/externalcom/AddXMLOrder.cfm?ClientSys=sukishufu");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'ClientUrl=SukuOffice01&OrderXML='.stripslashes($xmlToPost));

$btbResponse = curl_exec($ch);
curl_close($ch); 

strip slashes doesn't work? Any help welcome!


You most likely have magic_quotes turned on on your server. This will auto-add slashes to any POST / GET variable. I would turn that off and see if it fixes it (and remove the stripslashes section when done).

If you do not have access to modify the php.ini or not able to set that in the .htaccess file, you would need to stripslashes on the POST variable, not the $xmlToPost

0

精彩评论

暂无评论...
验证码 换一张
取 消