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.
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.
- 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.
-
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';
-
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';
<?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
));
This project is open source. You are encouraged to fork and submit pull requests.
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.