I need to do some basic Fedex package tracking. I'm using Jeremy Dunn's php-fedex-api-wrapper. My FedEx developer credentials are setup and I am able to authenticate via the FedEx api.
The problem: when I run a basic track request using the api-wrapper code I get back a result that I am unsure how to interpret. It looks like a structure that I should have no trouble parsing but I cannot.
Here are the first few lines of the result code that I see when I var_dump($trackReply)
object(FedEx\TrackService\ComplexType\TrackReply)#66 (2) {
["name":protected]=>
string(10) "TrackReply"
["values":protected]=>
array(4) {
If I cast the result as an array and print_r it looks like this (truncated version):
Array
(
[0] => FedEx\TrackService\ComplexType\TrackReply Object
(
[name:protected] => TrackReply
[values:protected] => Array
(
[HighestSeverity] => SUCCESS
[Notifications] => Array
(
[0] => FedEx\TrackService\ComplexType\Notification Object
(
[name:protected] => Notification
[values:protected] => Array
(
[Severity] => SUCCESS
[Source] => trck
[Code] => 0
[Message] => Request was successfully processed.
[LocalizedMessage] => Request was successfully
processed.
)
)
)
The $trackResult is obviously an object, but I cannot figure out how to access its specific properties. When it is cast as an array, element zero is clearly an object, so I would think I could access the object properties with
I tried $test = $trackResult[0];// which should now be an object, right? and then
I looked at this StackOverflow post and it seems to be relevant: Convert a PHP object to an associative array
So I tried one of the solutions from the link above: $array = json_decode(json_encode($nested_object), true); But, when I print_r($array) I get essentially an empty array like this:
Array
(
)