interaxiom / php-api
Wrapper for Interaxiom APIs
Requires
- guzzlehttp/guzzle: ^6.0
This package is auto-updated.
Last update: 2024-09-28 19:04:19 UTC
README
This PHP package is a lightweight wrapper for Interaxiom APIs. That's the easiest way to use interaxiom.com.au APIs in your PHP applications.
<?php /** * # Visit https://myaccount.interaxiom.com.au/#!user/api * to get your credentials */ require __DIR__ . '/vendor/autoload.php'; use \Interaxiom\Api; $api = new Api( $public_key, $private_key, $application_key, $endpoint ); echo "Welcome " . $api->get('/me')['response']['firstname']; ?>
Quickstart
To download this wrapper and integrate it inside your PHP application, you can use Composer.
Quick integration with the following command:
composer require interaxiom/php-api
Or add the repository in your composer.json file or, if you don't already have this file, create it at the root of your project with this content:
{ "name": "Example Application", "description": "This is an example of Interaxiom APIs wrapper usage", "require": { "interaxiom/php-api": "dev-master" } }
Interaxiom Examples
Do you want to use Interaxiom APIs? Maybe the script you want is already written in the example part of this repository!
How to print API error details?
Under the hood, php-api
uses GuzzlePHP 6 by default to issue API requests. If everything goes well, it will return the response directly as shown in the examples above. If there is an error like a missing endpoint or object (404), an authentication or authorization error (401 or 403) or a parameter error, the Guzzle will raise a GuzzleHttp\Exception\ClientException
exception. For server-side errors (5xx), it will raise a GuzzleHttp\Exception\ServerException
exception.
You can get the error details with a code like:
<?php require __DIR__ . '/vendor/autoload.php'; use \Interaxiom\Api; $api = new Api( $public_key, $private_key, $endpoint, $application_key ); try { echo "Welcome " . $api->get('/me')['firstname']; } catch (GuzzleHttp\Exception\ClientException $e) { $response = $e->getResponse(); $responseBodyAsString = $response->getBody()->getContents(); echo $responseBodyAsString; } ?>
Supported APIs
The following endpoints are available for public use:
My Account
$endpoint = 'myaccount';
- Documentation: https://www.interaxiom.com.au/knowledgebase/api/
- Customer Support: development@interaxiom.com.au
- Console: https://myaccount.interaxiom.com.au/#!api/
- Create application credentials: https://myaccount.interaxiom.com.au/#!user/api
Related links
- Contribute: https://github.com/interaxiom/php-api
- Report bugs: https://github.com/interaxiom/php-api/issues