我使用Inpost ShipX PHP SDK php库一快递公司后/创建航运使用API。
有了这个代码,我可以得到航运标签并保存,这工作正确:
$shipmentData = json_decode($response->getBody()->__toString(), true);
while ($shipmentData['status'] !== 'confirmed') {
sleep(1);
$response = $api->shipments()->get($shipmentData['id']);
$shipmentData = json_decode($response->getBody()->__toString(), true);
}
$labelResponse = $api->shipments()->label()->get($shipmentData['id'], [
'format' => 'Pdf',
'type' => 'A6',
]);
file_put_contents('var/labels/paczkomaty_label.pdf', $labelResponse->getBody()->__toString());
现在我也尝试获得创建航运跟踪号码。
我尝试添加到上面的代码:
$trackingResponse = $api->shipments()->tracking()->get($shipmentData['id']);
var_dump($trackingResponse);
但在发布后,我得到:
An uncaught Exception was encountered
Type: InvalidArgumentException
Message: tracking resource not found
Filename: /vendor/imper86/php-inpost-api/src/Resource/AbstractResource.php
Line Number: 66
有谁能检查这个库并帮助我正确地构建函数,或者给予我一个提示,我如何检查资源来构建正确的函数?
1条答案
按热度按时间ddrv8njm1#
/vendor/imper86/php-inpost-api/src/Resource/AbstractResource.php@66
内部的__call
代码:在您的示例中,它将是
Shipments\\Tracking
,但没有这样的类。试试
基本上你在
src/Resouce
目录中看到的东西可以作为方法调用。我刚刚执行了代码/结构的静态分析,可能是错误的