Skip to content

jtomka/auspost-api-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auspost API Client Library for PHP

This library is a Guzzle-based client for integrating PHP applications with Australia Post's web services.

Documentation on how to use this library can be found in the Postage Assessment Calculation and Postcode Search and the Delivery Choices specifications.

Table of Contents

Getting Started

Register to use Australia Post services

You will need to apply for an API key if you want to use the Postage Assessment Calculator and Postcode Search services. Similarly, you will also need to apply for permission to use the [Delivery Choices] dce-registration service.

Minimum requirements

  1. PHP 5.3.10 compiled with the cURL extension
  2. cURL 7.22.0

Note: The library is likely to work with earlier versions of PHP and cURL, but they have not been tested.

Install using Composer

  1. Add fontis/auspost-api-php as a Composer dependency in your project's composer.json file:
{
    "require": {
        "fontis/auspost-api-php": "*"
    }
}
  1. Download and install Composer into the repo:
$ curl -sS https://getcomposer.org/installer | php
  1. Install the library dependencies:
$ php composer.phar install
  1. Add the library to your PHP application:
require_once 'vendor/autoload.php';

Install using Git

  1. Clone this repo to an appropriate location:
$ git clone https://github.com/fontis/auspost-api-php
  1. Download and install Composer into the repo:
$ cd auspost-api-php
$ curl -sS https://getcomposer.org/installer | php
  1. Install the library dependencies:
$ php composer.phar install
  1. Add the library to your PHP application:
require_once 'vendor/autoload.php';

Quick Example

Calculate domestic parcel postage cost

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

use Auspost\Common\Auspost;
use Auspost\Postage\Enum\ServiceCode;

// Instantiate a Postage Assessment Calculator service
$client = Auspost::factory('/path/to/config.php')->get('postage');

$result = $client->calculateDomesticParcelPostage(array(
    'from_postcode' => 3000,
    'to_postocde' => 3011,
    'length' => 10,
    'width' => 10,
    'height' => 10,
    'weight' => 10,
    'service_code' => ServiceCode::AUS_PARCEL_REGULAR
));

Contributions

This project is open source. You are encouraged to fork and submit pull requests.

Guidelines

Please ensure your code adheres to the following guidelines in order for your pull request to be accepted.

  1. Follow the PHP-FIG standards recommendations - This library is written with adherence to the PSR-0, PSR-1 and PSR-2 standard recommendations.
  2. Write unit tests - Any new functionality should include corresponding tests.
  3. Add the licence header to new files - We would appreciate having licence headers been added to the top of new files.

About

Australia Post API client library for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%