у нас есть простой вызов GET API для API MYOB, который выглядит следующим образом
https://sampleclient.myobadvanced.com/entity/Default/18.200.001/Shipment?$filter=CreatedDateTime gt datetimeoffset'2020-04-01T00:00:00.000' and WarehouseID eq 'MELBOURNE'&$expand=ShippingSettings,ShippingSettings/ShipToAddress,ShippingSettings/ShipToContact,Details&$select=Status,ShipmentNbr,CustomerID,ShipVia,LocationID,WarehouseID,ShippingSettings,Details
Как видите, в URL есть пробелы, поэтому мне пришлось кодировать его следующим образом:
$url = 'https://sampleclient.myobadvanced.com/entity/Default/18.200.001/Shipment';
$query_params = "$filter=CreatedDateTime gt datetimeoffset'2020-04-05T00:00:00.000' and WarehouseID eq 'MELBOURNE'&$expand=ShippingSettings,ShippingSettings/ShipToAddress,ShippingSettings/ShipToContact,Details&$select=Status,ShipmentNbr,CustomerID,ShipVia,LocationID,WarehouseID,ShippingSettings,Details"
$api_url = $url . '?' . urlencode($query_params);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $finalURL,
CURLOPT_HEADER => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLINFO_HEADER_OUT => 1,
CURLOPT_VERBOSE => 1,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_COOKIESESSION => true
]);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type' => 'Content-Type: application/json']);
$curlResponse = curl_exec($curl);
Однако, когда запрос отправлен, я получаю неверные результаты, потому что 1 - он возвращает ДАННЫЕ, которые старше, чем фильтр CreatedDateTime, который мы указали, и 2 - подробности расширения не включаются в результаты. Я сравниваю результаты POSTMAN с нашим кодом, но не могу получить правильные результаты, полученные от POSTMAN.
POSTMAN RESULT:
{
"id": "e0931d53-1065-481c-b316-695f7cc216e4",
"rowNumber": 1,
"note": "",
"CreatedDateTime": {
"value": "2020-04-01T00:01:02.594938+00:00"
},
"CustomerID": {
"value": "019926"
},
"Details": [
{
"id": "38b844a2-9afe-4147-9fd6-9177fe13dc85",
"rowNumber": 1,
"note": "",
"Description": {
"value": "3.2kw inverter split system"
},
"ExpirationDate": {},
"FreeItem": {
"value": false
},
"InventoryID": {
"value": "ISR32J"
},
"LineNbr": {
"value": 1
},
"LocationID": {
"value": "ROWVILLE"
},
"LotSerialNbr": {
"value": ""
},
"OpenQty": {
"value": 0.0
},
"OrderedQty": {
"value": 1.000000
},
"OrderLineNbr": {
"value": 1
},
"OrderNbr": {
"value": "00093204"
},
"OrderType": {
"value": "SO"
},
"OriginalQty": {},
"ReasonCode": {},
"ShippedQty": {
"value": 1.000000
},
"UOM": {
"value": "EACH"
},
"WarehouseID": {
"value": "MELBOURNE"
},
"custom": {},
"files": []
}
],
"LocationID": {
"value": "MAIN"
},
"ShipmentNbr": {
"value": "020186"
},
"ShippingSettings": {
"id": "42e53016-8bd9-4604-8883-f585738afd13",
"rowNumber": 1,
"note": null,
"ShipToAddress": {
"id": "2a8455d2-a254-4705-8eb1-5f682c208384",
"rowNumber": 1,
"note": null,
"AddressLine1": {},
"AddressLine2": {},
"City": {},
"Country": {
"value": "AU"
},
"PostalCode": {},
"State": {},
"custom": {},
"files": []
},
"ShipToAddressOverride": {
"value": false
},
"ShipToContact": {
"id": "479e8c99-ed4c-4dad-900f-b6541f39e04e",
"rowNumber": 1,
"note": null,
"Attention": {},
"BusinessName": {
"value": "Elecool Elecrical"
},
"Email": {
"value": "glenn@elecool.com.au"
},
"Phone1": {
"value": "0418576387"
},
"custom": {},
"files": []
},
"ShipToContactOverride": {
"value": false
},
"custom": {},
"files": []
},
"ShipVia": {
"value": "LOCAL"
},
"Status": {
"value": "Completed"
},
"WarehouseID": {
"value": "MELBOURNE"
},
"custom": {},
"files": []
RESULT FROM CODE (ОБРАЗЕЦ):
{
"id": "8051dd65-d035-42ce-9546-e0c4573d205e"
"rowNumber": 1
"note": "Civic Job: 42717 for 29/3/2018"
"BaseCurrencyID": {
"value": "AUD"
}
"ControlQty": {
"value": 3
}
"CreatedDateTime": {
"value": "2018-03-29T01:44:12.95500:00"
}
"CurrencyID": []
"CurrencyRate": {
"value": 1
}
"CurrencyRateTypeID": []
"CurrencyViewState": {
"value": false
}
"CustomerID": {
"value": "AC153"
}
"EffectiveDate": {
"value": "2018-04-03T00:00:0000:00"
}
"FOBPoint": []
"FreightAmount": {
"value": 0
}
"FreightCost": {
"value": 0
}
"FreightCurrency": {
"value": "AUD"
}
"GroundCollect": {
"value": false
}
"Hold": {
"value": false
}
"Insurance": {
"LastModifiedDateTime": {
"value": "2018-04-04T05:49:17.30129600:00"
}
"LocationID": {
"value": "MAIN"
}
"Operation": {
"value": "Issue"
}
"Owner": []
"PackageCount": []
"PackageWeight": {
"value": 0
Как вы можете видеть, они различны, а результаты кода неполные. Что-то не так с запросами CURL?
PHP - это 7,2
Спасибо !!