Skip to content
Jay edited this page May 30, 2024 · 19 revisions

Welcome to SupportPal PHP API Client Wiki.

In this wiki, we will cover installing and using the client, all endpoints available including samples, and advanced settings.

Requirements

The API client has the following minimum system requirements:

  • SupportPal 5.0.0
  • PHP 8.1

Getting Started

Installation

The API client can be installed using Composer:

composer require supportpal/api-client-php

Configuration

Use of this library requires two components:

  • The hostname of your help desk installation, for example for https://www.example.com/support it would be example.com or for https://support.example.com it would be support.example.com.
  • An API token.

You can initialise the API client by creating an ApiContext.

$hostname = 'example.com';
$apiToken = 'JF9veGtKLw&8lVddyL9z14n&E3Y9JA65';

$context = new \SupportPal\ApiClient\Config\ApiContext($hostname, $apiToken);
$api = new \SupportPal\ApiClient\SupportPal($context);

Additional Configuration Options

Installations from sub-directories:

If your help desk runs from a sub directory, for example https://example.com/support, you can initialise the client like so:

$context = new \SupportPal\ApiClient\Config\ApiContext($hostname, $apiToken);
$context->setPath('support');

If you have not enabled pretty URLs, you will need to set the path to include index.php:

$context = new \SupportPal\ApiClient\Config\ApiContext($hostname, $apiToken);
$context->setPath('index.php/support');
Insecure connections:

By default the API client uses https. If you haven't setup an SSL certificate for your help desk you can switch to http:

$context = new \SupportPal\ApiClient\Config\ApiContext($hostname, $apiToken);
$context->disableSsl();
Disable SSL vertification:

If you're using a self-signed certificate, you will need to disable SSL verification:

$context = new \SupportPal\ApiClient\Config\ApiContext($hostname, $apiToken);
$requestDefaults = new \SupportPal\ApiClient\Config\RequestDefaults;
$requestDefaults->disableSslVerification();
$api = new \SupportPal\ApiClient\SupportPal($context, $requestDefaults);

Usage

The library's core class \SupportPal\ApiClient\SupportPal exposes an end point for each section of the API:

  • getCoreApi
  • getSelfServiceApi
  • getTicketApi
  • getUserApi

For example:

use SupportPal\ApiClient\Config\ApiContext;
use SupportPal\ApiClient\SupportPal;

$api = new SupportPal(new ApiContext('example.com', 'foo'));

echo $api->getCoreApi()->getSettings()->admin_folder; // "admin"

Find all the supported endpoints under the Reference section in the Wiki sidebar.