adampiotrowski/php-inpost-api

Inpost ShipX API 的 PHP SDK

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

This package is not auto-updated.

Last update: 2024-09-22 15:41:27 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 脚本

贡献

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