无法在PHP中分析响应对象数组
我正在尝试将配送API与我的应用程序集成。我将我的详细信息发送到SOAP客户机,并收到一个无法解析的对象数组作为返回。下面是数组。请帮我分析一下:无法在PHP中分析响应对象数组,php,oop,soap,response,Php,Oop,Soap,Response,我正在尝试将配送API与我的应用程序集成。我将我的详细信息发送到SOAP客户机,并收到一个无法解析的对象数组作为返回。下面是数组。请帮我分析一下: object(stdClass)#29 (4) { ["Transaction"]=> object(stdClass)#30 (5) { ["Reference1"]=> string(0) "" ["Reference2"]=> string(0)
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"];
我不能尝试太多,因为没有测试框架和服务,我必须手动取消我创建的所有发货。请告诉我该怎么办
提前感谢您的帮助。It'对象,而不是数组。您应该使用
->
访问该属性
$order = $response->Shipments->ProcessedShipment->Reference1;
它是一个对象,而不是数组。您应该使用
->
访问该属性
$order = $response->Shipments->ProcessedShipment->Reference1;
您可以使用
->
操作符访问对象的属性
$response->Shipments->ProcessedShipment->Reference1;
$response->Shipments->ProcessedShipment->ID;
$response->Shipments->ProcessedShipment->ShipmentLabel->LabelURL;
您可以使用
->
操作符访问对象的属性
$response->Shipments->ProcessedShipment->Reference1;
$response->Shipments->ProcessedShipment->ID;
$response->Shipments->ProcessedShipment->ShipmentLabel->LabelURL;
这不是一个数组,而是一个
stdClass
对象(通用对象)
您应该使用
$response->shippings->processedshipping->Reference1
这不是一个数组,而是一个stdClass
对象(通用对象)
您应该使用
$response->shippings->processedshipping->Reference1
这就是为什么它是一个对象,而不是数组。这就是为什么它是一个对象,而不是数组。