fourfiveone / publish-interactive-api
A package for interacting with Publish Interactive's RESTful API.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: >=5.4.0
- ext-curl: *
- vlucas/phpdotenv: >=3.0
Requires (Dev)
- phpunit/phpunit: ^6.2
This package is not auto-updated.
Last update: 2020-04-22 16:09:04 UTC
README
This is a package to simplify interacting the Publish Interactive RESTful API. This package does not manage the data being sent to the API or data received from the API. It is better to think of this package as a "helper" package sending requests to GET, POST, PUT, and DELETE endpoints.
Install
Requirements:
- PHP 5.4.0
- Composer
Install the composer dependencies:
composer install
That's it!
Use
Basic Usage:
use FourFiveOne\PublishInteractive\API\API;
...
$username = 'username';
$password = 'password';
$url = 'https://mysite.publishinteractive.com/api/v1';
$api = new API($username, $password, $url);
...
$parameters = [
'includeHidden' => true,
'includeDescendants' => true,
];
$response = $api->get('categories', $parameters);
if ($response['response_code'] == 200) {
...
} else {
...
}
The following REST verbs are available:
- GET
- POST
- PUT
- DELETE
The following functions are available for specific use cases:
attachment() - Upload an attachment to a report.
All functions return the following array:
$response['response_code'] // the http response code
$response['data'] // the JSON data returned as an associative array
Test
For the tests to run you need to create a .env file in the root directory. There is an example .env.example file to get you started. The file requires the username, password, and url to connect to your PI instance and run the tests.
Run the tests:
./vendor/bin/phpunit