sengentobv / colissimo-sdk

非官方Colissimo API PHP SDK

dev-master 2021-11-30 08:09 UTC

This package is auto-updated.

Last update: 2024-09-29 05:43:16 UTC


README

非官方Colissimo API PHP SDK

简单封装Colissimo SOAP API。

安装与使用

需求

PHP 7.4或更高版本。

请检查composer.json以获取所有需求列表。

Composer

推荐通过 Composer 安装此库。

composer require sengentobv/colissimo-sdk

手动安装

下载文件并包含 autoload.php

<?php
require_once('/path/to/colissimo-sdk/vendor/autoload.php');

入门

请遵循 安装过程,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure the authentication
$authentication = new \SengentoBV\ColissimoSdk\ColissimoAuthentication($CONTRACT_NUMBER, $PASSWORD);

// Create an instance of the client
$apiClient = new \SengentoBV\ColissimoSdk\ColissimoApiClient($authentication);

try {
    // Get an instance of the SLS service
    $slsService = $apiClient->getSlsService();
        
    // Perform a call
    // NOTE: You have to leave the contract number/password empty as the authentication information will be (over)written automatically!
    $result = $slsService->checkGenerateLabel(new \SengentoBV\ColissimoSdk\Soap\SlsService\Structs\ColissimoApiCheckGenerateLabel(...))
    print_r($result);
    
} catch (\Exception $e) {
    echo $e->getMessage();
}

API端点

以下Web服务已被封装/映射。

授权

Colissimo API使用自定义方法进行认证(使用相同的凭据集)。

此库旨在帮助您完成此操作!

每次创建新的请求对象时,您都可以(应该)留出用于认证的字段为空,因为这个库将通过自动填充(或覆盖)这些字段来为您完成繁重的工作。

测试

要运行测试,请使用

composer install
vendor/bin/phpunit