定制 schiggi/gls-cee-shipping-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

schiggi/gls-cee-shipping-api

Composer 安装命令:

composer require schiggi/gls-cee-shipping-api

包简介

API for GLS Shipping & Tracking in Eastern Europe

README 文档

README

GLS shipping API for Eastern Europa (HU, RO, SK, CZ, SI, HR) GLS webservice interface via SOAP-XML requests

Installing

The easiest way to install the API is using Composer:

composer require schiggi/gls-cee-shipping-api

Then use your framework's autoload, or simply add:

<?php
  require 'vendor/autoload.php';

Getting started

You can start making requests to the GLS API just by creating a new API instance

<?php
    $api = new GLS\API([
        'username'          => 'teszt',
        'password'          => 'teszt',
        'client_number'     => '100000004',
        'country_code'      => 'HU'
    ]);

The API class takes care of the communication between your app and the GLS servers via SOAP-XML requests.

Using Monolog to log requests and responses to a log file

Monolog is used optionally to log request/responses with DPD server.

You need to specific a log dir when creating a new API instance. Log files while have the name "api-gls-consumer-{date}.log". If omitted, no logs will be written.

<?php
  $api = new GLS\API([
    'username'          => 'teszt',
    'password'          => 'teszt',
    'client_number'     => '100000004',
    'country_code'      => 'HU',
    'log_dir'  => dirname(__FILE__).'/'
  ]);
 

General usage

Send parcel data to GLS

<?php
// Parcel generation. Data will be validated before sending.
$parcel_generate[] = array(
    'SenderName' => 'Company Kft.',
    'SenderAddress' => 'Ady Endre ut 104',
    'SenderCity' => 'Budapest',
    'SenderZipcode' => '1072',
    'SenderCountry' => 'HU',
    // Not mandatory
    'SenderContact' => 'Contact Axanne',
    'SenderPhone' => '06202156156',
    'SenderEmail' => 'teszt@teszt.hu',
    //
    'ConsigName' => 'Alex Schikalow',
    'ConsigAddress' => 'Teszt ut 1',
    'ConsigCity' => 'Budapest',
    'ConsigZipcode' => '1025',
    'ConsigCountry' => 'HU',
    // Not mandatory
    'ConsigContact' => 'Alex Schikalow',
    'ConsigPhone' => '06301245879',
    'ConsigEmail' => 'alex@alex.hu',
    //

    'ClientRef' => '14050',
    'CodAmount' => 0,
    'CodRef' => '',
    'Pcount' => 1,
    'PickupDate' => '2018-02-26',
    'Services' => array(
        "24H" => "",
        "FDS" => "alex@alex.hu",
        "FSS" => "+362012345648",
    ),
);

// Will return the parcel numbers for each clientRef order from GLS or error message
$parcel_numbers = $api->getParcelNumbers($parcel_generate);
var_dump($parcel_numbers);
Array
(
  [14050] => 00201084696
)

Print labels for saved and sent parcels

<?php
// Array of parcel numbers from GLS. Client / order ids optional. Can also be a numeric array.
$parcel_numbers = array(
    '14050' => 00201084696
);

// Returns array with success message and pdf stream
$printed_parcels = $api->getParcelLabels($prepared_parcels);
var_dump($printed_parcels);
Array
(
    [status] => 'success'
    [error_description] => 'Error Description. Empty, if success'
    [pdf] => is streamed labels. Use echo and correct pdf header to display
)

You can set, which paper size and how many labels should be printed on pdf. For that, you need to specific a label paper size when creating a new API instance. Available options are "A6", "A6_PP", "A6_ONA4", "A4_2x2", "A4_4x1" and "T_85x85". Default is "A4_2x2".

<?php
$api = new GLS\API([
    'username'          => 'teszt',
    'password'          => 'teszt',
    'client_number'     => '100000004',
    'country_code'      => 'HU-TEST',
    'label_paper_size'  => 'A4_2x2',
]);

Delete parcel

<?php
// Array of parcel numbers from GLS. Order references are optional. Can be numerical array.
$delete_parcels = Array
(
    '14050' => '00209053638',
    '14051' => '00209053637'
);

// Returns array with success message or error description
$deleted_parcels = $api->deleteParcels($delete_parcels);
var_dump($deleted_parcels);
Array
(
    [00209053638] => 'success'
    [00209053637] => 'Parcel already deleted'
)

If one parcel has a problem, then no parcel will be deleted from the request array.

Retrieve parcel status

<?php
// returns status message as string for parcel_number. One number at a time.
$status_msg = $api->getParcelStatus('123456789');

Retrieve parcel status link

<?php
// returns url link for parcel number. One number at a time.
$status_msg = $api->$api->getTrackingUrl('123456789');

schiggi/gls-cee-shipping-api 适用场景与选型建议

schiggi/gls-cee-shipping-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 432 次下载、GitHub Stars 达 12, 最近一次更新时间为 2018 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 schiggi/gls-cee-shipping-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 schiggi/gls-cee-shipping-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 schiggi/gls-cee-shipping-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 3
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-02-27