定制 janar/smartpost-shipping-php 二次开发

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

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

janar/smartpost-shipping-php

Composer 安装命令:

composer require janar/smartpost-shipping-php

包简介

Simple client library for PHP to create shipments using smartpost web service

README 文档

README

API changed in 2023 Q1 https://smartpost.sendsmaily.net/templates/e4e01c50-639d-4b3b-9d16-e9401d60a7ec/html/ I have not tested that does this implementation here still work.

Client library for Itella Smartpost API written in PHP.

Simple PHP client for creating Itella Smartpost (http://uus.smartpost.ee/) parcels via web API. Can be used to automate parcel creation and getting shipping labels for them.

Communication is done using XML. Original Smartpost API documents can be found here: http://uus.smartpost.ee/ariklient/ostukorvi-rippmenuu-lisamise-opetus/automaatse-andmevahetuse-opetus

Currently this library is in development, but shipments to parcel terminals (Estonia and Finland) work. Also you can request shipping labels from API. So you would never have to enter Smartpost client area.

  • Uses CURL for requests.
  • Many requests and features not here yet.

Installation

Easiest way to install the library is through Composer:

$ composer require janar/smartpost-shipping-php

Basic usage

Most basic and useful feature in this library would be creating shipments on your own server. Removes need for manual exporting/importing CSV files to Smartpost environment.

Creating shipments:

$spApi = new Client( "smartpost username", "smartpost password" );

//create shipments
$shipment = new Shipment();
$shipment->setRecipient( new Recipient( "John Doe", "56666661", "john.doe@doe123.com" ) );
$shipment->setReference( '[MyAwsomeWebShop] - test #1' );
$shipment->setDestination( new ParcelTerminal( 172 ) );
$spApi->addShipment( $shipment );

$shipment = new Shipment();
$shipment->setRecipient( new Recipient( "John Doe2", "56666662", "john.doe2@doe123.com" ) );
$shipment->setReference( '[MyAwsomeWebShop] - test #2' );
$shipment->setDestination( new ParcelTerminal( 171 ) );
$spApi->addShipment( $shipment );

$shipment = new Shipment();
$shipment->setRecipient( new Recipient( "John Doe3", "56666663", "john.doe3@doe123.com" ) );
$shipment->setDestination( new ParcelTerminal( null, "3202", "00215" ) );
$spApi->addShipment( $shipment );

$result = $spApi->postShipments();

Creating shipments result:

Alt text

Shipments in Smartpost dashboard:

Alt text

3. Retrieving shipping labels (as pdf document)

Shipping labels are generated on Smartpost side and they are in pdf format. Only format and barcode(s) / tracking codes are needed to get labels on pdf. Formats are following:

Format Description
A5 1 label on A5 sized paper
A6 1 label on A6 sized paper
A6-4 4 labels fitted on A6 sized paper
A7 1 label on A7 sized paper
A7-8 8 labels fitted on A7 sized paper
A6 1 label on A6 sized paper

Labels are on one continuous pdf document. You can choose what to do with result. Save as file or view in browser.

$spApi = new Client( "smartpost username", "smartpost password" );
$trackingCodes = array( '6895100008876963', '6895100008876964' );
$result = $spApi->getShippingLabels( $trackingCodes, 'A6-4' );

if( $result === false  ){
  echo $spApi->getLastError() . "<br />";
} else {
  //Here we stream pdf directly to browser, but you may also save returned content as file for local use. 
  header("Content-type:application/pdf");
  header("Content-Disposition:inline;filename='shipping-labels.pdf'");
  echo $result;
  exit;
}

Results would look something like this:

Alt text

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-08-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固