I've tried the following:
<?php
$user = 'myusername';
$xml_data = "<AddressValidateRequest USERID='$user'>" .
"<IncludeOptionalElements>true</IncludeOptionalElements>" .
"<ReturnCarrierRoute>true</ReturnCarrierRoute>" .
"<Address ID='0'>" .
"<FirmName />" .
"<Address1 />" .
"<Address2>205 bagwell ave</Address2>" .
"<City>nutter fort</City>" .
"<State>wv</State>" .
"<Zip5></Zip5>" .
"<Zip4></Zip4>" .
"</Address>" .
"</AddressValidateRequest>";
$url = "http://production.shippingspis.com/ShippingAPI.dll";
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Following line is compulsary to add as it is:
curl_setopt($ch, CURLOPT_POSTFIELDS,
"?API=Verify&XML=" . $xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$output = curl_exec($ch);
curl_close($ch);
$array_data = json_decode(json_encode(simplexml_load_string($output)), true);
print_r('<pre>');
print_r($array_data);
print_r('</pre>');
echo PHP_EOL;
?>
I get no response nor any kind of an error. Can anyone lead me in the right direction?
I have tried to follow several examples that I found on the web but I can't seem to hit upon the solution.
My code is based on the example in this post:
Send XML data to webservice using php curl
Working Code follows
<?php
$user = 'myusername';
$xml_data = "<AddressValidateRequest USERID='$user'>" .
"<IncludeOptionalElements>true</IncludeOptionalElements>" .
"<ReturnCarrierRoute>true</ReturnCarrierRoute>" .
"<Address ID='0'>" .
"<FirmName />" .
"<Address1>$address1></Address1>" .
"<Address2>$address2</Address2>" .
"<City>$city</City>" .
"<State>$state</State>" .
"<Zip5></Zip5>" .
"<Zip4></Zip4>" .
"</Address>" .
"</AddressValidateRequest>";
$url = "http://production.shippingapis.com/ShippingAPI.dll?API=Verify";
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Following line is compulsary to add as it is:
curl_setopt($ch, CURLOPT_POSTFIELDS,
'XML=' . $xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$output = curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
$array_data = json_decode(json_encode(simplexml_load_string($output)), true);
print_r('<pre>');
print_r($array_data);
print_r('</pre>');
echo PHP_EOL;
?>