PHP: REST XML Query
// The XML can be loaded in a String, or a file. (Sample XML below)
// If the XML is in a file you must include the XML header tag, otherwise you can exclude it.
$handle = curl_init();
curl_setopt_array(
$handle,
array(
CURLOPT_URL => 'http://location',
CURLOPT_POST => true,
// On POST_FIELDS you may need a string before hand, eg: 'serviceRequest=' .
CURLOPT_POSTFIELDS => $xml,
CURLOPT_RETURNTRANSFER => true,
// If Authentication is required
CURLOPT_USERPWD => sprintf('%s:%s', 'user', 'pass'),
CURLOPT_HTTPAUTH => CURLAUTH_BASIC | CURLAUTH_ANY,
CURLOPT_SSL_VERIFYPEER => false,
)
);
$response = curl_exec($handle);
curl_close($handle);
$xml = new SimpleXMLElement($response);
// Print the Array to see the result..
echo '<pre>';
print_r($xml);
echo '</pre>';
<?xml version="1.0" encoding="UTF-8"?>
<requestEnvelope>
<requestHeader>
<controlData>
<userID>user</userID>
<password>pass</password>
</controlData>
<processData>
<operationName>quickSearch</operationName>
</processData>
</requestHeader>
<searchRequest>
<startDate>10/25/2011</startDate>
<endDate>12/25/2013</endDate>
<regionCode>USA</regionCode>
</searchRequest>
</requestEnvelope>