i am working on a UPS tracking API, i have called the API to track the package, i am getting the right response, but in array format, i am new to json decoding, please tell me how to parse this in PHP, do i have to create multiple objects in PHP? i am attaching the output as well as the PHP code.
PHP Code
if (isset($_POST['af0'])) {
if (preg_match('/^[a-z\d_]{4,80}$/i', $_POST['trackingNumber'])) {
$cleanTrackingNumber = $_POST['trackingNumber'];
$someArray = upsTrack("$cleanTrackingNumber");
echo '<pre>'; print_r($someArray); echo '</pre>';
} else {
echo 'Invalid tracking number... sigh...';
}
}
Output
Array
(
[TRACKRESPONSE] => Array
(
[RESPONSE] => Array
(
[TRANSACTIONREFERENCE] => Array
(
[XPCIVERSION] => 1.0
)
[RESPONSESTATUSCODE] => 1
[RESPONSESTATUSDESCRIPTION] => Success
)
[SHIPMENT] => Array
(
[SHIPPER] => Array
(
[SHIPPERNUMBER] => A6161A
[ADDRESS] => Array
(
[ADDRESSLINE1] => 132 E 43RD ST
[CITY] => NEW YORK
[STATEPROVINCECODE] => NY
[POSTALCODE] => 10017 4019
[COUNTRYCODE] => US
)
)
[SHIPTO] => Array
(
[ADDRESS] => Array
(
[CITY] => TORONTO
[STATEPROVINCECODE] => ON
[POSTALCODE] => M5V3X1
[COUNTRYCODE] => CA
)
)
[SHIPMENTWEIGHT] => Array
(
[UNITOFMEASUREMENT] => Array
(
[CODE] => LBS
)
[WEIGHT] => 3.20
)
[SERVICE] => Array
(
[CODE] => 011
[DESCRIPTION] => STANDARD
)
[REFERENCENUMBER] => Array
(
[CODE] => 13
[VALUE] => A6161AD9HPK
)
[SHIPMENTIDENTIFICATIONNUMBER] => 1ZA6161A6832763249
[PICKUPDATE] => 20140519
[SCHEDULEDDELIVERYDATE] => 20140521
[PACKAGE] => Array
(
[TRACKINGNUMBER] => 1ZA6161A6832763249
[ACTIVITY] => Array
(
[ACTIVITYLOCATION] => Array
(
[ADDRESS] => Array
(
[CITY] => SECAUCUS
[STATEPROVINCECODE] => NJ
[COUNTRYCODE] => US
)
)
[STATUS] => Array
(
[STATUSTYPE] => Array
(
[CODE] => I
[DESCRIPTION] => DEPARTURE SCAN
)
[STATUSCODE] => Array
(
[CODE] => DP
)
)
[DATE] => 20140520
[TIME] => 053000
)
[MESSAGE] => Array
(
[CODE] => 01
[DESCRIPTION] => On Time
)
[PACKAGEWEIGHT] => Array
(
[UNITOFMEASUREMENT] => Array
(
[CODE] => LBS
)
[WEIGHT] => 3.20
)
[REFERENCENUMBER] => Array
(
[CODE] => 19
[VALUE] => MMTD71EUY061A
)
)
)
)
)
If you already have the output in Array format then you don't have anything more to do with json decoding.
You can use $someArray to get any data from the array.
It's up to you if you want to just display it or save it, for example in a database.
What is it you trying to accomplish?
Related
I've an associative array. I am attempting to create each sub array within a loop and insert it into a multidimensional array. Google suggested using array_merge, but after using 'print_r' on the multidimensional array with the code below, only the last sub-array is being displayed.
Array
(
[data] => Array
(
[0] => Array
(
[candidate] => Array
(
[id] => 184
[firstName] => skg
[lastName] => s
[address] => Array
(
[address1] => sakthi
[address2] =>
[city] =>
[state] =>
[zip] =>
[countryID] => 1
[countryName] => United States
[countryCode] => US
)
[hourlyRate] => 0
)
[jobOrder] => Array
(
[id] => 88
[title] => Tech Analyst
)
)
[1] => Array
(
[candidate] => Array
(
[id] => 852
[firstName] => mso cool
[lastName] =>
[address] => Array
(
[address1] =>
[address2] =>
[city] =>
[state] =>
[zip] =>
[countryID] => 1
[countryName] => United States
[countryCode] => US
)
[hourlyRate] => 0
)
[jobOrder] => Array
(
[id] => 57
[title] => Tester
)
)
And Another Array like this :
[rating] => Array
(
[0] => 7
[1] => 5
[2] =>
)
How to get merge this array value into previous array values like
Array
(
[data] => Array
(
[0] => Array
(
[candidate] => Array
(
[id] => 184
[firstName] => skg
[lastName] => s
[address] => Array
(
[address1] => sakthi
[address2] =>
[city] =>
[state] =>
[zip] =>
[countryID] => 1
[countryName] => United States
[countryCode] => US
)
[hourlyRate] => 0
[rating] => 7
)
[jobOrder] => Array
(
[id] => 88
[title] => Tech Analyst
)
)
[1] => Array
(
[candidate] => Array
(
[id] => 852
[firstName] => mso cool
[lastName] =>
[address] => Array
(
[address1] =>
[address2] =>
[city] =>
[state] =>
[zip] =>
[countryID] => 1
[countryName] => United States
[countryCode] => US
)
[hourlyRate] => 0
[rating] => 5
)
[jobOrder] => Array
(
[id] => 57
[title] => Tester
)
)
I tried lot of tricks but couldn't get the desired array format. Can any one help me in this to get the desired array? Thanks in advance.
$arr = array(); //filled with data
$rating = array(); //filled with rates
foreach ( $rating as $key =>$rate ) {
$arr['data'][ $key ]['rating'] = $rate;
}
<?php
$arr=Array(
'data'=>Array(
0=>Array('candidate'=>Array()),
1=>Array('candidate'=>Array())
)
);
$rating=Array(7,5);
foreach($rating as $key=>$val){
$arr['data'][$key]['rating']=$val;
}
print_r($arr);
Returns:
Array
(
[data] => Array
(
[0] => Array
(
[candidate] => Array
(
)
[rating] => 7
)
[1] => Array
(
[candidate] => Array
(
)
[rating] => 5
)
)
)
I have a working PHP app running in Bluemix that I want to extend to call a RESTful service (Insights for Twitter). I've been able to call the service, retrieve the json body, and use json_decode as follows to create an array:
$insightList = json_decode($guzzleResponse ->getBody(), true);
However, I can't figure out how to get access to the field I'm interested in. I've searched for solution on the web and tried a few approaches that looked promising, but when I tried to integrate them, I couldn't get them to work. I'm a bit of a PHP novice, so if something doesn't work I'm not sure how to proceed.
The json structure is quite complex, with three top-level arrays - search, tweets, and next. I'm interested in the second of these, tweets. It's a pretty complex array - there is one entry per tweet. The field I want right now is tweets.cde.message.body. You can find the full schema here: https://cdeservice.eu-gb.mybluemix.net/rest-api/#!/messages/getTweets
This is the code I have so far:
foreach($insightList as $cde) {
foreach($cde as $message) {
$insight = $message['body'];
if(strlen($insight) > 60) {
$posts[] = array(
'id' => 99999999,
//Temp; remove links from the text
'text' => $insight,
'category' => $insightCategory,
'image' => 'false'
);
}
}
}
Here's a print_r of $insightList:
[search] => Array (
[results] => 28
[current] => 28
)
[tweets] => Array (
[0] => Array (
[cde] => Array (
[author] => Array (
[gender] => male
[parenthood] => Array (
[isParent] => unknown
)
[location] => Array (
[country] =>
)
[maritalStatus] => Array (
[isMarried] => unknown
)
)
[content] => Array (
[sentiment] => Array (
[evidence] => Array ( )
[polarity] => NEUTRAL
)
)
)
[message] => Array (
[postedTime] => 2015-01-13T09:42:16.000Z
[verb] => share
[link] => http://twitter.com/zWDOM/statuses/554936456477933569
[generator] => Array (
[displayName] => Twitter Web Client
[link] => http://twitter.com
)
[body] => RT #VisualSuccess: "Mainframe & Cloud" Magazine wurde soeben publiziert! http://www.twitter.com #zWDOM #Rocket #JohnKnutson_IBM
[favoritesCount] => 0
[objectType] => activity
[actor] => Array (
[summary] => Seit über 25 Jahren im Mainframebereich, derzeit als Senior Consultant und IT Architekt für zEnterprise und Projektmanager beim IBM BP Cancom in Köln
[image] => https://pbs.twimg.com/profile_images/424202233463308288/XQquUcnh_normal.jpeg
[statusesCount] => 2309
[utcOffset] => 3600
[languages] => Array (
[0] => de
)
[preferredUsername] => zWDOM
[displayName] => Willi Domroese
[postedTime] => 2009-12-17T01:39:25.000Z
[link] => http://www.twitter.com/zWDOM
[verified] =>
)
[provider] => Array (
[displayName] => Twitter
[link] => http://www.twitter.com
[objectType] => service
)
[twitter_filter_level] => medium
[twitter_entities] => Array (
[urls] => Array (
[0] => Array (
[display_url] => ln.is/paper.li/visua…
[indices] => Array (
[0] => 77
[1] => 99
)
[expanded_url] => http://ln.is/paper.li/visualsucce/7zYNk
[url] => http://www.twitter.com
)
)
[hashtags] => Array ( )
[user_mentions] => Array (
[0] => Array (
[indices] => Array (
[0] => 3
[1] => 17
)
[screen_name] => VisualSuccess
[id_str] => 213337792
[name] => Predrag Gasic
[id] => 213337792
)
[1] => Array (
[indices] => Array (
[0] => 101
[1] => 107
)
[screen_name] => zWDOM
[id_str] => 97334013
[name] => Willi Domroese
[id] => 97334013
)
[2] => Array (
[indices] => Array (
[0] => 108
[1] => 115
)
[screen_name] => Rocket
[id_str] => 870584947
[name] => Rocket Software
[id] => 870584947
)
[3] => Array (
[indices] => Array (
[0] => 116
[1] => 132
)
[screen_name] => JohnKnutson_IBM
[id_str] => 16452310
[name] => John Knutson
[id] => 16452310
)
)
[trends] => Array ( )
[symbols] => Array ( )
)
[twitter_lang] => de
[id] => tag:search.twitter.com,2005:554936456477933569
[retweetCount] => 1
[gnip] => Array (
[urls] => Array (
[0] => Array (
[expanded_url] => http://linkis.com/paper.li/visualsucce/7zYNk
[expanded_status] => 200
[url] => http://www.twitter.com
)
)
[language] => Array (
[value] => de
)
)
[object] => Array (
[postedTime] => 2015-01-13T08:04:48.000Z
[verb] => post
[link] => http://twitter.com/VisualSuccess/statuses/554911928527888384
[generator] => Array (
[displayName] => Linkis.com
[link] => http://linkis.com
)
[body] => "Mainframe & Cloud" Magazine wurde soeben publiziert! http://www.twitter.com ://www.twitter.com
[objectType] => activity
[actor] => Array (
[summary] => Ù† (N), Wirtschaftsinformatiker | SAP Consultant Logistics #bigdata #appdevelopment #webdesign #eCommerce #SocialMedia #contentmarketing #SmartHome #Journal
[image] => https://pbs.twimg.com/profile_images/2841607223/959b0d23646b1f24bd7b70deac160e2f_normal.jpeg
[statusesCount] => 14185
[utcOffset] => 3600
[languages] => Array (
[0] => de
)
[preferredUsername] => VisualSuccess
[displayName] => Predrag Gasic
[postedTime] => 2010-11-08T17:19:27.000Z
[link] => http://www.twitter.com/VisualSuccess
[verified] =>
)
[provider] => Array (
[displayName] => Twitter
[link] => http://www.twitter.com
[objectType] => service
)
[twitter_filter_level] => low
[twitter_entities] => Array (
[urls] => Array (
[0] => Array (
[display_url] => ln.is/paper.li/visua…
[indices] => Array (
[0] => 58
[1] => 80
)
[expanded_url] => http://ln.is/paper.li/visualsucce/7zYNk
[url] => http://www.twitter.com
)
)
[hashtags] => Array ( )
[user_mentions] => Array (
[0] => Array (
[indices] => Array (
[0] => 82
[1] => 88
)
[screen_name] => zWDOM
[id_str] => 97334013
[name] => Willi Domroese
[id] => 97334013
)
[1] => Array (
[indices] => Array (
[0] => 89
[1] => 96
)
[screen_name] => Rocket
[id_str] => 870584947
[name] => Rocket Software
[id] => 870584947
)
[2] => Array (
[indices] => Array (
[0] => 97
[1] => 113
)
[screen_name] => JohnKnutson_IBM
[id_str] => 16452310
[name] => John Knutson
[id] => 16452310
)
)
[trends] => Array ( )
[symbols] => Array (
)
)
)
)
)
Answers to this question would be greatly appreciated
Iterating $insightList will not get you to the cde level. And you don't actually want the cde; you want the message.
Just iterate the tweets. You don't need a foreach to get keyed info from a PHP array.
foreach($insightList['tweets'] as $tweet) {
$insight = $tweet['message']['body'];
if(strlen($insight) > 60) {
$posts[] = array(
'id' => 99999999,
//Temp; remove links from the text
'text' => $insight,
'category' => $insightCategory,
'image' => 'false'
);
}
}
It looks to me from your print_r that what you want is at:
echo $insightList[0]['message']['body'];
When there's a section like this [some_key], then 'some_key' is an associative array key, and you can access those elements be they additional arrays or a value, using the key name, as I illustrated here.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This is my array
Array
(
[TrackResponse] => Array
(
[Response] => Array
(
[TransactionReference] => Array
(
[CustomerContext] => RocketShipIt
)
[ResponseStatusCode] => 1
[ResponseStatusDescription] => Success
)
[Shipment] => Array
(
[Shipper] => Array
(
[ShipperNumber] => 746354
[Address] => Array
(
[AddressLine1] => 11 PINE ST
[City] => NEW BEDFORD
[StateProvinceCode] => MA
[PostalCode] => 01032 9785
[CountryCode] => US
)
)
[ShipTo] => Array
(
[Address] => Array
(
[City] => FOUNTAIN HILLS
[StateProvinceCode] => AZ
[PostalCode] => 85268
[CountryCode] => US
)
)
[ShipmentWeight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
)
[Weight] => 1.00
)
[Service] => Array
(
[Code] => 003
[Description] => GROUND
)
[ShipmentIdentificationNumber] => 746463772264354327
[PickupDate] => 20140709
[DeliveryDateUnavailable] => Array
(
[Type] => Scheduled Delivery
[Description] => Scheduled Delivery Date is not currently available, please try back later
)
[Package] => Array
(
[TrackingNumber] => 746463772264354327
[Activity] => Array
(
[0] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => FOUNTAIN HILLS
[StateProvinceCode] => AZ
[PostalCode] => 85268
[CountryCode] => US
)
[Code] => ML
[Description] => FRONT DOOR
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => D
[Description] => DELIVERED
)
[StatusCode] => Array
(
[Code] => FS
)
)
[Date] => 20140716
[Time] => 142400
)
[1] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => TEMPE
[StateProvinceCode] => AZ
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => OUT FOR DELIVERY
)
[StatusCode] => Array
(
[Code] => DS
)
)
[Date] => 20140716
[Time] => 041900
)
[2] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => TEMPE
[StateProvinceCode] => AZ
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => ARRIVAL SCAN
)
[StatusCode] => Array
(
[Code] => AR
)
)
[Date] => 20140715
[Time] => 114500
)
[3] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => HODGKINS
[StateProvinceCode] => IL
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => DEPARTURE SCAN
)
[StatusCode] => Array
(
[Code] => DP
)
)
[Date] => 20140711
[Time] => 144600
)
[4] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => HODGKINS
[StateProvinceCode] => IL
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => LOCATION SCAN
)
[StatusCode] => Array
(
[Code] => LC
)
)
[Date] => 20140711
[Time] => 090500
)
[5] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => HODGKINS
[StateProvinceCode] => IL
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => UNLOAD SCAN
)
[StatusCode] => Array
(
[Code] => UL
)
)
[Date] => 20140711
[Time] => 085300
)
[6] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => HODGKINS
[StateProvinceCode] => IL
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => ARRIVAL SCAN
)
[StatusCode] => Array
(
[Code] => AR
)
)
[Date] => 20140711
[Time] => 061900
)
[7] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => W SPRINGFIELD
[StateProvinceCode] => MA
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => DEPARTURE SCAN
)
[StatusCode] => Array
(
[Code] => DP
)
)
[Date] => 20140709
[Time] => 213400
)
[8] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => W SPRINGFIELD
[StateProvinceCode] => MA
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => I
[Description] => ORIGIN SCAN
)
[StatusCode] => Array
(
[Code] => OR
)
)
[Date] => 20140709
[Time] => 183400
)
[9] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[City] => W SPRINGFIELD
[StateProvinceCode] => MA
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => P
[Description] => PICKUP SCAN
)
[StatusCode] => Array
(
[Code] => PU
)
)
[Date] => 20140709
[Time] => 163200
)
[10] => Array
(
[ActivityLocation] => Array
(
[Address] => Array
(
[CountryCode] => US
)
)
[Status] => Array
(
[StatusType] => Array
(
[Code] => M
[Description] => BILLING INFORMATION RECEIVED
)
[StatusCode] => Array
(
[Code] => MP
)
)
[Date] => 20140709
[Time] => 112842
)
)
[PackageWeight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
)
[Weight] => 1.00
)
)
)
)
)
I'm looking to access values in the Activity numeric indexed array like such.
foreach($response as $row)
{
foreach($row['Shipment']['Package'] as $k)
{
echo $k['ActivityLocation']['Address']['City'];
}
}
I wanna be able to access the values inside of the numeric keyed array, and print them out in a row 1-10 etc.
The error i'm getting is Fatal error: Cannot use string offset as an array in test.php on line 287
If anybody could help me solve this you would be the bestus!
Please and Thanks
foreach($row['Shipment']['Package'] as $k)
{
echo $k['ActivityLocation']['Address']['City'];
}
I download the ShippingGroundFreightWebService PHP examples from UPS.com. I got following error message:
SoapFault Object
(
[message:protected] => An exception has been raised as a result of client data.
[string:private] =>
[code:protected] => 0
[file:protected] => /home5/vizparts/public_html/PHP/SoapGroundFreightShipClient.php
[line:protected] => 193
[trace:private] => Array
(
[0] => Array
(
[file] => /home5/vizparts/public_html/PHP/SoapGroundFreightShipClient.php
[line] => 193
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => ProcessShipment
[1] => Array
(
[0] => Array
(
[Request] => Array
(
[RequestOption] => Array
(
[0] => 1
[1] => Shipping
)
)
[Shipment] => Array
(
[ShipFrom] => Array
(
[Name] => Pat Stewart
[TaxIdentification] => 1234567890
[Address] => Array
(
[AddressLine] => 2311 York Road
[City] => Timonium
[StateProvinceCode] => MD
[PostalCode] => 21093
[CountryCode] => US
)
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
[Extension] => 123
)
)
[ShipperNumber] => 222006
[ShipTo] => Array
(
[Name] => Superman
[Address] => Array
(
[AddressLine] => 2010 Warsaw Road
[StateProvinceCode] => GA
[PostalCode] => 30076
[CountryCode] => US
[City] => Roswell
)
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
[Extention] => 111
)
)
[PaymentInformation] => Array
(
[Payer] => Array
(
[Name] => Superman
[Address] => Array
(
[AddressLine] => 2010 Warsaw Road
[City] => Roswell
[StateProvinceCode] => GA
[PostalCode] => 30075
[CountryCode] => US
)
[ShipperNumber] => 00613270
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
)
)
[ShipmentBillingOption] => Array
(
[Code] => 10
[Description] => String
)
)
[Service] => Array
(
[Code] => 308
[Description] => String
)
[HandlingUnitOne] => Array
(
[Quantity] => 16
[Type] => Array
(
[Code] => PLT
[Description] => String
)
)
[Commodity] => Array
(
[CommodityID] => 22
[Description] => BUGS
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => String
)
[Value] => 511.25
)
[Dimensions] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => IN
[Description] => String
)
[Length] => 1.25
[Width] => 1.2
[Height] => 5
)
[NumberOfPieces] => 1
[PackagingType] => Array
(
[Code] => PLT
[Description] => String
)
[CommodityValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 265.2
)
[FreightClass] => 60
[NMFCCommodityCode] => 566
)
[Reference] => Array
(
[Number] => Array
(
[Code] => PM
[Value] => 1651651616
)
[BarCodeIndicator] => Array
(
[NumberOfCartons] => 5
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => String
)
[Value] => 2
)
)
)
)
)
)
)
)
)
[faultstring] => An exception has been raised as a result of client data.
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
[detail] => stdClass Object
(
[Errors] => stdClass Object
(
[ErrorDetail] => stdClass Object
(
[Severity] => Hard
[PrimaryErrorCode] => stdClass Object
(
[Code] => 9121000
[Description] => Invalid Ship Request Document
)
)
)
)
)
I want to integrate the UPS API into my own website. I want to print the shipping label. How to fix this problem?
you should set the request xsd file,find it in other folder in the package you download.then set the request file with it.
I'm trying to run the PHP test for the UPS Freight Shipping API that came with the official UPS SDK. I finally got it to connect to the SOAP service with a correct username, password, and API key, but now I'm getting an error that I don't know how to solve. The error coming back from the server is
Invalid Ship Request Document
The full response from the server looks like this:
SoapFault Object
(
[message:protected] => An exception has been raised as a result of client data.
[string:private] =>
[code:protected] => 0
[file:protected] => /my_home_dir/UPS_API/test.php
[line:protected] => 224
[trace:private] => Array
(
[0] => Array
(
[file] => /my_home_dir/UPS_API/test.php
[line] => 224
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => ProcessFreightRate
[1] => Array
(
[0] => Array
(
[Request] => Array
(
[RequestOption] => RateChecking Option
)
[ShipFrom] => Array
(
[Name] => Good Incorporation
[Address] => Array
(
[AddressLine] => 2010 WARSAW ROAD
[City] => Roswell
[StateProvinceCode] => GA
[PostalCode] => 30076
[CountryCode] => US
)
)
[ShipTo] => Array
(
[Name] => Sony Company Incorporation
[Address] => Array
(
[AddressLine] => 2311 YORK ROAD
[City] => TIMONIUM
[StateProvinceCode] => MD
[PostalCode] => 21093
[CountryCode] => US
)
)
[PaymentInformation] => Array
(
[Payer] => Array
(
[Name] => Payer inc
[Address] => Array
(
[AddressLine] => 435 SOUTH STREET
[City] => RIS TOWNSHIP
[StateProvinceCode] => NJ
[PostalCode] => 07960
[CountryCode] => US
)
)
[ShipmentBillingOption] => Array
(
[Code] => 10
[Description] => PREPAID
)
)
[Service] => Array
(
[Code] => 308
[Description] => UPS Freight LTL
)
[HandlingUnitOne] => Array
(
[Quantity] => 20
[Type] => Array
(
[Code] => PLT
[Description] => PALLET
)
)
[Commodity] => Array
(
[CommodityID] =>
[Description] => No Description
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => Pounds
)
[Value] => 750
)
[Dimensions] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => IN
[Description] => Inches
)
[Length] => 23
[Width] => 17
[Height] => 45
)
[NumberOfPieces] => 45
[PackagingType] => Array
(
[Code] => BAG
[Description] => BAG
)
[DangerousGoodsIndicator] =>
[CommodityValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 5670
)
[FreightClass] => 60
[NMFCCommodityCode] =>
)
[ShipmentServiceOptions] => Array
(
[PickupOptions] => Array
(
[HolidayPickupIndicator] =>
[InsidePickupIndicator] =>
[ResidentialPickupIndicator] =>
[WeekendPickupIndicator] =>
[LiftGateRequiredIndicator] =>
)
[OverSeasLeg] => Array
(
[Dimensions] => Array
(
[Volume] => 20
[UnitOfMeasurement] => Array
(
[Code] => CF
[Description] => String
)
)
[Value] => Array
(
[Cube] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 5670
)
)
[COD] => Array
(
[CODValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 363
)
[CODPaymentMethod] => Array
(
[Code] => M
[Description] => For Company Check
)
[CODBillingOption] => Array
(
[Code] => 01
[Description] => Prepaid
)
[RemitTo] => Array
(
[Name] => RemitToSomebody
[Address] => Array
(
[AddressLine] => 640 WINTERS AVE
[City] => PARAMUS
[StateProvinceCode] => NJ
[PostalCode] => 07652
[CountryCode] => US
)
[AttentionName] => C J Parker
)
)
[DangerousGoods] => Array
(
[Name] => Very Safe
[Phone] => Array
(
[Number] => 453563321
[Extension] => 1111
)
[TransportationMode] => Array
(
[Code] => CARGO
[Description] => Cargo Mode
)
)
[SortingAndSegregating] => Array
(
[Quantity] => 23452
)
[CustomsValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 23457923
)
[HandlingCharge] => Array
(
[Amount] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 450
)
)
)
)
)
)
)
)
)
[faultstring] => An exception has been raised as a result of client data.
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
[detail] => stdClass Object
(
[Errors] => stdClass Object
(
[ErrorDetail] => stdClass Object
(
[Severity] => Hard
[PrimaryErrorCode] => stdClass Object
(
[Code] => 9121000
[Description] => Invalid Ship Request Document
)
)
)
)
)
The code that I am using to make the request can be found here (credentials have been removed for security): http://pastebin.com/Yw7sPQdg
Turns out that I was pointing to the wrong end point. The endpoint url for freight rates should be: https://wwwcie.ups.com/webservices/FreightRate