trackops / trackops-client-php
PHP Client for Trackops REST API. See http://support.trackops.com
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: ~6.3
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2024-01-16 17:48:14 UTC
README
The Trackops API Client for PHP provides an easy to use set of tools to quickly access your Trackops data from any PHP application.
Installation
PHP 5.6+ (compiled with cURL) and Composer are required for installation.
If you don't already have composer installed, you can quickly do so by running this command from your project root directory:
curl -sS https://getcomposer.org/installer | php
Once you have composer, install the trackops/trackops-client-php package from Packagist, like so:
composer require trackops/trackops-client-php
Alternatively, you can manually add trackops/trackops-client-php to your composer.json, like so:
{ "require": { "trackops/trackops-client-php": "~0.2" } }
Once the package is successfully installed with composer, install the dependencies like so:
composer install
Getting Started
It only takes a few lines of code to get a working example up and running:
Basic Example of Usage
Use the get()
method to retrieve a set of records
// require the composer autoloader require 'vendor/autoload.php'; use Trackops\Api\Client; $api = new Client('subdomain', 'username', 'apitoken'); $records = $api->createRequest()->get('cases')->toArray();
Using Query Parameters
We're passing a $params
variable with an array of query parameters to this request.
require 'vendor/autoload.php'; use Trackops\Api\Client; $api = new Client('subdomain', 'username', 'apitoken'); $params = ['from' => '2016-01-01', 'to' => '2016-01-31', 'dir' => 'asc', 'per_page' => 1, 'page' => 1]; $records = $api->createRequest()->get('cases', $params)->toArray();
Visit the Trackops Developer API Reference for a full list of endpoints and query parameters.
Counting Results
Use the count()
method to quickly get the total record_count
and page_count
of your query.
require 'vendor/autoload.php'; use Trackops\Api\Client; $api = new Client('subdomain', 'username', 'apitoken'); $params = ['from' => '2016-01-01', 'to' => '2016-01-31']; $records = $api->createRequest()->count('cases', $params)->toArray();
Tip: For more advanced implementations, take a look at the examples
directory in the project source code.