imper86/php-inpost-api

Inpost ShipX API 的 PHP SDK

v1.1.9 2021-10-29 07:05 UTC

This package is auto-updated.

Last update: 2024-09-23 14:44:24 UTC


README

安装

composer require imper86/php-inpost-api

HTTPlug 注意

这个库使用了 HTTPlug,因此不依赖于任何 HTTP 客户端。为了使用这个库,您必须安装一些 PSR-18 HTTP 客户端PSR-17 HTTP 工厂。如果您不知道要安装哪个,可以要求这些

composer require php-http/guzzle6-adapter http-interop/http-factory-guzzle

用法

使用这个库非常简单,快速示例应该足以理解其工作方式。

use Imper86\PhpInpostApi\InpostApi;
use Imper86\PhpInpostApi\Plugin\AcceptLanguagePlugin;

// if you want to use all resources you must ask Inpost for
// access token via their contact form
// https://inpost.pl/formularz-wsparcie
$token = 'aaaa.aaaa';

// create api client
$api = new InpostApi($token);

// this library provides optional Plugin for localizing
// error messages

$api->addPlugin(new AcceptLanguagePlugin('pl_PL'));

// from now you can use these api methods:
$api->addressBooks()->(...);
$api->batches()->(...);
$api->dispatchOrders()->(...);
$api->dispatchPoints()->(...);
$api->mpks()->(...);
$api->organizations()->(...);
$api->points()->(...);
$api->sendingMethods()->(...);
$api->services()->(...);
$api->shipments()->(...);
$api->shipmentTemplates()->(...);
$api->statuses()->(...);
$api->tracking()->(...);

// fast example:
var_dump($api->organizations()->shipments()->get('1234'));

如果您使用带类型提示的 IDE,如 PHPStorm,您会很容易理解。如果不是,请查看 Resource 目录

示例

如果您仍然想知道如何使用这个库,请查看示例 PHP 脚本

贡献

任何帮助都将非常感激 :)