我正在尝试将发货API与我的应用集成。我将我的详细信息发送到SOAP客户端,我正在接收一个对象数组作为回报,我无法解析。以下是阵列。请帮我解析一下:
object(stdClass)#29 (4) {
["Transaction"]=>
object(stdClass)#30 (5) {
["Reference1"]=>
string(0) ""
["Reference2"]=>
string(0) ""
["Reference3"]=>
string(0) ""
["Reference4"]=>
string(0) ""
["Reference5"]=>
string(0) ""
}
["Notifications"]=>
object(stdClass)#31 (0) {
}
["HasErrors"]=>
bool(false)
["Shipments"]=>
object(stdClass)#32 (1) {
["ProcessedShipment"]=>
object(stdClass)#33 (8) {
["ID"]=>
string(10) "42939401"
["Reference1"]=>
string(9) "100000002"
["Reference2"]=>
string(0) ""
["Reference3"]=>
string(0) ""
["ForeignHAWB"]=>
string(0) ""
["HasErrors"]=>
bool(false)
["Notifications"]=>
object(stdClass)#34 (0) {
}
["ShipmentLabel"]=>
object(stdClass)#35 (2) {
["LabelURL"]=>
string(76) "http://content/rpt_cache/9c0d152bbcdc4e739132d2dsda5506.pdf"
["LabelFileContents"]=>
NULL
}
}
}
}
我在$response
变量中接受了此回复并尝试了以下操作,但这些都不起作用:
echo $order = $response["Shipments"]["ProcessedShipment"]["Reference1"];
echo $hawb = $response["Shipments"]["ProcessedShipment"]["ID"];
echo $barcode = $response["Shipments"]["ProcessedShipment"]["ShipmentLabel"]["LabelURL"];
我不能尝试太多,因为没有测试框架,我必须手动取消我创建的所有货件。请告诉我该怎么做。
提前感谢所有帮助。
答案 0 :(得分:3)
它是对象,而不是数组。您应该使用->
访问该媒体资源。
$order = $response->Shipments->ProcessedShipment->Reference1;
答案 1 :(得分:1)
使用->
运算符访问对象的属性
$response->Shipments->ProcessedShipment->Reference1;
$response->Shipments->ProcessedShipment->ID;
$response->Shipments->ProcessedShipment->ShipmentLabel->LabelURL;
答案 2 :(得分:1)
这不是一个数组,它是一个stdClass
对象(一般对象)。
您应该使用$response->Shipments->ProcessedShipment->Reference1