0

有什么方法可以设置 cURL 以使用&lt;and&lt;而不是<and发送此 XML>

    $xml_data = '
    <Shipping_Address>
    <Province>BC</Province>
    <Country>Canada</Country>
    <PostalCode>V6P 5T2</PostalCode>
    <Phone>604-561-7977</Phone>
    </Shipping_Address>';

$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml','charset=ISO-8859-1'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
4

1 回答 1

0

如果 web 服务需要 XML,这似乎很奇怪。但如果是,你应该可以通过调用来做到这一点htmlentities()

$xml_data = htmlentities('
    <Shipping_Address>
    <Province>BC</Province>
    <Country>Canada</Country>
    <PostalCode>V6P 5T2</PostalCode>
    <Phone>604-561-7977</Phone>
    </Shipping_Address>');
于 2012-12-17T20:09:28.477 回答