diglin/swisspost-barcode-php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

diglin/swisspost-barcode-php-sdk

Composer 安装命令:

composer require diglin/swisspost-barcode-php-sdk

包简介

PHP SDK for the use of SwissPost Barcode Webservice

README 文档

README

This SDK allows to use the SwissPost Barcode Webservice to generate Label or Barcode for shipment. Tracking code are returned from the API and can be used for later use.

Installation via Composer

Add the following requirements into your composer.json at root project level. You do not need to add an autoloader, composer will handle it for you if your application is compatible with it.

composer require diglin/swisspost-barcode-php-sdk

OR

 {
    "require" : {
        "diglin/barcode-swisspost-php-sdk": "1.*"
    },
    "repositories" : [
        {
            "type": "vcs",
            "url": "git@github.com:diglin/barcode-swisspost-php-sdk.git"
        }
    ]
 }

Usage

You can see some examples into the file tutorial.php or the test cases into the test/ServiceType folder.

For example to generate a Barcode:

    /**
     * Minimal options
     */
    $options = array(
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_URL      => $this->config->getWsdl(),
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_LOGIN    => $this->config->getLogin(),
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_PASSWORD => $this->config->getPassword(),
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_CLASSMAP => \Diglin\Swisspost\ClassMap::get(),
    );
    
    $generate = new \Diglin\Swisspost\ServiceType\Generate($options);

    $barcodeDefinition = new \Diglin\Swisspost\StructType\BarcodeDefinition();
    $barcodeDefinition
        ->setBarcodeType(\Diglin\Swisspost\EnumType\BarcodeType::VALUE_LSO_1)
        ->setImageFileType('PNG')
        ->setImageResolution(300);

    $struct = new \Diglin\Swisspost\StructType\GenerateBarcode($this->config->getLanguage(), $barcodeDefinition);

    try {
        /* @var $response GenerateBarcodeResponse */
        if ($generate->GenerateBarcode($struct) !== false) {
            $response = $generate->getResult();
        } else {
            $response = $generate->getLastError();
        }

        // PNG Picture to use further
        $barcode = $response->getData()->getBarcode();
        
        // ... your code here

    } catch (\SoapFault $e) {
        switch ($e->faultcode) {
            case 'HTTP':
                echo 'Login and/or password is not correct' . PHP_EOL;
                break;
            default:
                echo sprintf('Error occurred with the SOAP interface with the error message "%s"', $e->faultstring);
                break;
        }
    }

Generate classes for new API version

run composer install && php -f Generator.php

Changelog

See CHANGELOG.md file

License

MIT License

Author

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固