discimport/pakkelabels 问题修复 & 功能扩展

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

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

discimport/pakkelabels

最新稳定版本:1.1.1

Composer 安装命令:

composer require discimport/pakkelabels

包简介

PHP-SDK to communicate with Pakkelabels.dk

README 文档

README

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Total Downloads License

PHP SDK for Pakkelabels.dk API from the Danish shipping service Pakkelabels.dk.

This is a modified version of the officially supported version on Pakkelabels.dk API. This version has composer integration, tests, following PSR2 coding standards and better error handling.

Getting started

Below is a simple PHP script which illustrate the minimum amount of code needed to getting started.

<?php
    use Pakkelabels\Pakkelabels;

    try {
      $label = new Pakkelabels('api_user', 'api_key');
    } catch (PakkelabelsException $e) {
      echo $e->getMessage();
    }
?>

Once the $label object is created, you can begin to use the API.

To see the current balance:

<?php
    echo $label->balance();
?>

To list all Post Danmark shipments sent to to Denmark:

<?php
    $labels = $label->shipments(array('shipping_agent' => 'pdk', 'receiver_country' => 'DK'));
    print_r($labels);
?>

To display the PDF for the shipment ID with 42 inline in the browser:

<?php
    $base64 = $label->pdf(42);
    $pdf = base64_decode($base64);
    header('Content-type: application/pdf');
    header('Content-Disposition: inline; filename="label.pdf"');
    echo $pdf;
?>

To create a test shipment with Post Danmark, and then output the Track&Trace number of the newly created shipment:

<?php
    $data = array(
      'shipping_agent' => 'pdk',
      'weight' => '1000',
      'receiver_name' => 'John Doe',
      'receiver_address1' => 'Some Street 42',
      'receiver_zipcode' => '5230',
      'receiver_city' => 'Odense M',
      'receiver_country' => 'DK',
      'sender_name' => 'John Wayne',
      'sender_address1' => 'The Batcave 1',
      'sender_zipcode' => '5000',
      'sender_city' => 'Odense C',
      'sender_country' => 'DK',
      'delivery' => 'true',
      'test' => 'true' // Change to false when going live
    );

    $shipment = $label->createShipment($data);
    echo 'Track&Trace: ' . $shipment['pkg_no'];
?>

Official library

You can find the official library at Github

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-08