Добрый день!
Пробую сделать отслеживание заказа по api
wiki.courierexe.ru/,
Пользуюсь примером обращения к сервису на PHP.
Создаю функцию
public function tracking($orderno){
$results = $this->sendRequest($this->makeXML('statusreq', ['orderno' => $orderno]));
$attrsStatusHistory = $results->order->statushistory->status->attributes();
$order = array();
foreach ($results as $result) {
$order = array(
'order' => array(
'orderno' => $orderno,
'weight' => (string)$result->weight,
'price' => (string)$result->price,
'barcode' => (string)$result->barcode,
'return' => (string)$result->return,
'quantity' => (string)$result->quantity,
'paytype' => (string)$result->paytype,
'print_check' => (string)$result->print_check,
'service' => (string)$result->service,
'return_service' => (string)$result->return_service,
'type' => (string)$result->type,
'return_type' => (string)$result->return_type,
'waittime' => (string)$result->waittime,
'inshprice' => (string)$result->inshprice,
'receiverpays' => (string)$result->receiverpays,
'status' => (string)$result->status,
'customstatecode' => (string)$result->customstatecode,
'deliveredto' => (string)$result->deliveredto,
'delivereddate' => (string)$result->delivereddate,
'deliveredtime' => (string)$result->deliveredtime,
'sender' => array(
'company' => (string)$result->sender->company,
'person' => (string)$result->sender->person,
'phone' => (string)$result->sender->phone,
'town' => (string)$result->sender->town,
'address' => (string)$result->sender->address,
'date' => (string)$result->sender->date,
'time_min' => (string)$result->sender->time_min,
'time_max' => (string)$result->sender->time_max,
'contacts' => array(
'phone' => (string)$result->sender->contacts->phone,
'email' => (string)$result->sender->contacts->email
),
),
'receiver' => array(
'company' => (string)$result->receiver->company,
'person' => (string)$result->receiver->person,
'phone' => (string)$result->receiver->phone,
'zipcode' => (string)$result->receiver->zipcode,
'town' => (string)$result->receiver->town,
'address' => (string)$result->receiver->address,
'date' => (string)$result->receiver->date,
'time_min' => (string)$result->receiver->time_min,
'time_max' => (string)$result->receiver->time_max,
'contacts' => array(
'phone' => (string)$result->receiver->contacts->phone,
'email' => (string)$result->receiver->contacts->email
),
),
'statushistory' => array(
'status' => array(
'eventstore' => $attrsStatusHistory['eventstore'],
'eventtime' => $attrsStatusHistory['eventtime'],
'createtimegmt' => $attrsStatusHistory['createtimegmt'],
'title' => $attrsStatusHistory['title']
),
),
),
);
}
return $order;
}
Все выводит нормально
Array
(
[order] => Array
(
[orderno] => ks_nata_3683
[weight] => 0.1
[price] => 25180.00
[barcode] => 000308041
[return] => NO
[quantity] => 1
[paytype] => CASH
[print_check] => YES
[service] => 1
[return_service] => 1
[type] => 1
[return_type] => 1
[waittime] => 0
[inshprice] => 0.00
[receiverpays] => NO
[status] => COMPLETE
[customstatecode] => 1
[deliveredto] => досавлено
[delivereddate] => 2020-03-03
[deliveredtime] => 15:40:00
[sender] => Array
(
[company] => ТЕСТМ
[person] => Мария
[phone] => 79873936436
[town] => Москва город
[address] => Красная площадь, 1
[date] =>
[time_min] =>
[time_max] =>
[contacts] => Array
(
[phone] => +79873936436
[email] =>
)
)
[receiver] => Array
(
[company] => Test-name gsdf
[person] => Test-name gsdf
[phone] => 1234567890
[zipcode] => 141018
[town] => Санкт-Петербург город
[address] => Лебединая ул.
[date] => 2020-03-03
[time_min] => 10:00:00
[time_max] => 18:00:00
[contacts] => Array
(
[phone] => +71234567890
[email] =>
)
)
[statushistory] => Array
(
[status] => Array
(
[eventstore] => SimpleXMLElement Object
(
[0] => Web-службы
)
[eventtime] => SimpleXMLElement Object
(
[0] => 2020-03-03 15:11:10
)
[createtimegmt] => SimpleXMLElement Object
(
[0] => 2020-03-03 12:11:10
)
[title] => SimpleXMLElement Object
(
[0] => Новый
)
)
)
)
)
все получилось вывести, кроме истории статусов
Выводит только один статус новый, а в данном примере должно быть два статуса новый и доставлен, как правильно сформировать условие, чтобы выводилось все статусы в истории статусов. Заранее спасибо.