承接 sp-express/php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sp-express/php-sdk

最新稳定版本:v1.0.1

Composer 安装命令:

composer require sp-express/php-sdk

包简介

README 文档

README

Latest Version on Packagist Software License PHP-CS-Fixer Psalm Static analysis

The SP Express SDK makes it easy for developers to access sp.express API.

SP Express

Disclaimer

Please note that not all API methods are currently implemented in this SDK. If you need functionality that is not available in the SDK:

  • You can make raw API requests directly to the SP Express API
  • Consider opening an issue on our Github Issue Tracker to request the missing functionality

Jump To:

Getting Started

  1. Sign up – Before you begin, you need to obtain a login and API key from your salesman. Contact can be found in your panel
  2. Minimum requirements – To run the SDK, your system needs to have PHP 8.1 or higher with the cURL extension installed.
  3. Install the SDK – Using Composer is the recommended way to install the SP Express SDK for PHP:
    composer require sp-express/php-sdk
    

Quick Examples

Create a client

<?php
// Require the Composer autoloader:
require 'vendor/autoload.php';

use SpExpress\Sdk\Client\ApiClient;

// Instantiate an SP Express client: 
$client = new ApiClient('login', 'api_key');

Create a courier pre-routing

<?php

use SpExpress\Sdk\Exceptions\ApiException;
use SpExpress\Sdk\Objects\Input\AddressObj;
use SpExpress\Sdk\Objects\Input\CustomsDutyObj;
use SpExpress\Sdk\Objects\Input\Options2Obj;
use SpExpress\Sdk\Objects\Input\OptionsPreRoutingObj;
use SpExpress\Sdk\Objects\Input\PackageObj;

try {
    $package = new PackageObj();
    $package->weight = 1;
    $package->size_d = 10;
    $package->size_l = 30;
    $package->size_w = 25;
    $package->value = 10;
    $package->value_currency = "PLN";
    $package->content = 'Books';
   
    $sender = new AddressObj();
    $sender->name = 'Anna Nowak';
    $sender->country = 'PL';
    $sender->email = 'anna.nowak@example.pl';
    $sender->city = 'Warszawa';
    $sender->address_line_1 = 'Krakowska 12/34';
    $sender->tel = '987654321';
    $sender->zip_code = '00-111';
   
    $receiver = new AddressObj();
    $receiver->company = 'ABC Corporation';
    $receiver->country = 'PL';
    $receiver->email = 'delivery@example.pl';
    $receiver->city = 'Kraków';
    $receiver->address_line_1 = 'Długa 5/55';
    $receiver->tel = '111222333';
    $receiver->zip_code = '12-345';
   
    $options = new OptionsPreRoutingObj();
    $options2 = new Options2Obj();
    $customsDuty = new CustomsDutyObj();


    $result = $client
        ->courierPreRouting()
        ->create($package, $sender, $receiver, $options, $options2, $customsDuty);

    $numberOfPackages = $result->getNumber(); // number of packages
    $packages = $result->getPackages(); // array with packages

    foreach ($packages as $package) {
        var_dump($package->getLabels()); // array with labels (one package can contain multiple labels)
        var_dump($package->getPackageId()); // package Id
    }
} catch (ApiException $exception) {
    // exception message contains general information
    var_dump($exception->getMessage());

    // for more detailed information
    var_dump($exception->getError()->getErrorCode());
    var_dump($exception->getError()->getDescription());
    var_dump($exception->getError()->getDetails());
}

Cancel a courier pre-routing

$client
    ->courierPreRouting()
    ->cancel(['483231127136528']);

Getting Help

Bug reports and feature requests can be submitted on the Github Issue Tracker. Feel free to open an issue on every question you have.

Contributing

We work hard to provide a high-quality and useful SDK, and we greatly value feedback and contributions from our community.

License

sp-express/php-sdk is released under the MIT License. See the bundled LICENSE.md for details.

统计信息

  • 总下载量: 3.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-22