mannysoft / auspost-api-php
Auspost API Client Library for PHP
Requires
- php: ^7.1
- php-http/client-common: ^2.0.0
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.6
- php-http/httplug: ^2.0
- php-http/message: ^1.7
- php-http/message-factory: ^1.0.2
Requires (Dev)
- php-http/guzzle6-adapter: 2.0.1
- phpunit/phpunit: 7.5.2
This package is not auto-updated.
Last update: 2024-11-13 21:50:06 UTC
README
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
- PHP 5.3.10 compiled with the cURL extension
- 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
-
Add
fontis/auspost-api-php
as a Composer dependency in your project'scomposer.json
file:{ "require": { "fontis/auspost-api-php": "*" } }
-
Download and install Composer into the repo:
$ curl -sS https://getcomposer.org/installer | php
-
Install the library dependencies:
$ php composer.phar install
-
Add the library to your PHP application:
require_once 'vendor/autoload.php';
Install using Git
-
Clone this repo to an appropriate location:
$ git clone https://github.com/fontis/auspost-api-php
-
Download and install Composer into the repo:
$ cd auspost-api-php $ curl -sS https://getcomposer.org/installer | php
-
Install the library dependencies:
$ php composer.phar install
-
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_postcode' => 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.
- Follow the PHP-FIG standards recommendations - This library is written with adherence to the PSR-0, PSR-1 and PSR-2 standard recommendations.
- Write unit tests - Any new functionality should include corresponding tests.
- Add the licence header to new files - We would appreciate having licence headers been added to the top of new files.