定制 sendworks/sendworks-php 二次开发

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

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

sendworks/sendworks-php

Composer 安装命令:

composer require sendworks/sendworks-php

包简介

PHP Client bindings for Sendworks Shipping API

README 文档

README

#sendworks-php

Sendworks API wrapper for PHP

This library wraps the Sendworks REST API in an object-oriented PHP interface. For a full specification of the REST API, please have a look at https://sendworks.com/documentation/

##Usage

You can use the library by cloning this repository into a subfolder of your application and include the file include_all.php.

Alternatively, you can use Composer to load the library. Just type:

composer require sendworks/sendworks-php

##Getting started

To use, first create a connection instance, using your api key:

<?php
require '/path/to/sendworks-php/include_all.php';
// Replace this with your actual api key
$api_key = 'YOUR_KEY_HERE';
// Connect to sandbox
$sendworks = new Sendworks\Connection($api_key, 'api.sandbox.sendworks.com');

This connects you to the test environment (sandbox). The sandbox is similar to the production setup, but nothing you do will actually be sent to the carriers and labels won't be valid.

You should replace YOUR_KEY_HERE with your actual api key.

You can now use the connection to get a quote:

$recipient = new Sendworks\Address(['post_code' => 2860, 'country_code' => 'DK']);
$order = new Sendworks\Order(['subtotal' => '200 DKK']);
var_dump($sendworks->products->select($recipient, $order));

And to create a shipment:

$recipient = new Sendworks\Address([
  'name' => 'Lorem von Ipsum',
  'street1' => 'Mars Alle 1',
  'post_code' => 2860,
  'city' => 'Søborg',
  'country_code' => 'DK',
  'email' => 'tkn@sendworks.com',
  'phone' => '12345678',
]);
$parcel = new Sendworks\Parcel([]);
$products = $sendworks->products->select($recipient);
$shipment = new Sendworks\Shipment(['recipient' => $recipient, 'parcels' => [$parcel], 'product' => $products[0]]);
$shipment->shipment_reference = "TEST:" . time();
$shipment = $sendworks->shipments->save($shipment);
$shipment = $sendworks->shipments->buy($shipment);
var_dump($shipment);

See also examples.php.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固