'.$email.'
'.$passwd.'
'.$server.'
023YAHOO
'.$warehouse.'
Sheridan Rawlins
321 Foo bar lane
Apartment #2
Nowhere
CA
US United States
12345
555.444.3210
sheridan@rawlins.com
GD
-
12345
1
-
12345
1
'.$warehouse.'
Bob Smith
This Lane
#333
Bob
NV
US United States
89110
555.444.3210
smith@rawlins.com
GD
-
12345
1
'.$warehouse.'
Sheridan Rawlins
321 Foo bar lane
Apartment #2
Nowhere
CA
US United States
12345
555.444.3210
sheridan@rawlins.com
UPS Ground
-
654654
1
';
//Convert characters to proper format for post
$OrderList = urlencode($OrderList);
// open synchronous connection to Shipwire servlet
// NOTE: you must have the cURL libraries installed with PHP on your server--
// If you need them, see your System Administrator, who can get then at
// http://curl.haxx.se/download.html
$urlConn = curl_init ("https://www.shipwire.com/exec/FulfillmentServices.php");
curl_setopt ($urlConn, CURLOPT_POST, 1);
curl_setopt ($urlConn, CURLOPT_HTTPHEADER, array("Content-type", "application/x-www-form-urlencoded"));
curl_setopt ($urlConn, CURLOPT_POSTFIELDS, "OrderListXML=".$OrderList);
curl_setopt ($urlConn, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($urlConn, CURLOPT_SSL_VERIFYPEER, 0);
$orderSubmitted = curl_exec($urlConn);
if (empty($orderSubmitted)) {
print "ERROR: " . curl_error($urlConn) . "\n";
exit;
}
// Parse the response
$parser= xml_parser_create();
xml_parse_into_struct($parser,$orderSubmitted,$XMLvals,$XMLindex);
xml_parser_free($parser);
// This function will return an array of the values of an element
// given the $vals and $index arrays, and the element name
function getElementValue($XMLvals, $elName) {
$elValue = null;
foreach ($XMLvals as $arrkey => $arrvalue) {
foreach ($arrvalue as $key => $value) {
if ($value==strtoupper($elName)){
$elValue[] = $arrvalue['value'];
}
}
}
return $elValue;
}
// Use the above function to get the values you want using element names, e.g.
$errorMessage = getElementValue($XMLvals,"ErrorMessage");
$totalOrders = getElementValue($XMLvals,"TotalOrders");
$transactionId = getElementValue($XMLvals,"TransactionId");
echo
"
Sample PHP for Shipwire XML Orders
Sample PHP Shipwire XML Order Submitter
";
// Print the tag values we extracted
echo "Here is the data extracted from the Shipwire response XML:
";
if (!empty($errorMessage)) {
foreach ($errorMessage as $key => $err) {
echo "Error Message: ".$err."
";
}
}
if (!empty($totalOrders)) {
foreach ($totalOrders as $key => $tot) {
echo "Total Orders: ".$tot."
";
}
}
if (!empty($transactionId)) {
foreach ($transactionId as $key => $tra) {
echo "Transaction ID: ".$tra."
";
}
}
echo "";
?>