Download the PHP package benmorel/gls-tracker without Composer
On this page you can find all versions of the php package benmorel/gls-tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download benmorel/gls-tracker
More information about benmorel/gls-tracker
Files in benmorel/gls-tracker
Package gls-tracker
Short Description A library to track GLS parcels using the GLS Track & Trace Web API
License MIT
Informations about the package gls-tracker
GLS Tracker
A PHP library to track GLS parcels using the GLS Track & Trace Web API.
Installation
This library is installable via Composer:
Requirements
This library requires PHP 7.1 or later.
Project status & release process
This library is under development.
The current releases are numbered 0.x.y
. When a non-breaking change is introduced (adding new methods, optimizing
existing code, etc.), y
is incremented.
When a breaking change is introduced, a new 0.x
version cycle is always started.
It is therefore safe to lock your project to a given release cycle, such as 0.1.*
.
If you need to upgrade to a newer release cycle, check the release history
for a list of changes introduced by each further 0.x.0
version.
Quickstart
First, instantiate the tracker with your GLS API username & password:
You can optionally pass a language code as third parameter, to get results returned in another language (defaults to en
):
You can now track a single parcel:
Or track several parcels at once:
Note that there is a limit on the number of search results that may be returned by the API in a single call.
If you request too many TrackIDs at a time, you may get a TooManySearchResultsException
.
Error handling
If an error occurs while querying the API, a GLSTrackerException
is always thrown.
Exception hierarchy:
GLSTrackerException
Base class for all exceptions.Exception\APIException
A well-known error response has been received from the API.Exception\APIException\InputValidationException
An invalid TrackID has been given.Exception\APIException\MissingRightsException
The user can access the API but doesn't have the necessary rights.Exception\APIException\NotAuthorizedException
The username or password is incorrect.Exception\APIException\TooManySearchResultsException
Too many search results would be returned; you should request less TrackIDs.Exception\APIException\UserAccountBlockedException
The user account is blocked.
Exception\InvalidResponseException
An invalid response has been received from the API, and this library cannot decode it.Exception\NetworkException
A network error occurred and no response has been received from the API.
These fine-grained exceptions allow you to act automatically upon each type of failure.
For example, when receiving a NetworkException
, you may schedule a retry a few moments later.