helpspot/helpspot

A PHP wrapper for the HelpSpot help desk api

1.0.5 2023-09-26 20:09 UTC

This package is not auto-updated.

Last update: 2024-04-23 22:48:12 UTC


README

This is the PHP SDK to the HelpSpot API. The SDK can work with both the public and private (staff) API.

Please read the full documentation for each API method here:

Install

Via Composer

$ composer require helpspot/helpspot

Loading

If your framework handles autoloading you can simply use a use statement at the top of your php file to access HelpSpot. If it doesn't, you can load in HelpSpot with the require statement shown below plus using the use statement at the top of the file you want to access HelpSpot in.

require_once "vendor/autoload.php";

use helpspot\helpspot\helpspot;

// Access HelpSpot in your functions and methods in this file

Usage

Authentication

You can authenticate either via an api key or a username and password combination. The API key is now the recommended authentication method and is the only method available if the HelpSpot instance uses SAML or LDAP authentication.

API Key:

$helpspot = new helpspot('https://company.helpspot.com', '', '','apikey');

Username Password:

$helpspot = new helpspot('https://company.helpspot.com', 'user@example.com', 'password');

Create a request using the private api

$helpspot = new helpspot('https://company.helpspot.com', 'user@example.com', 'password');

$helpspot->post('private.request.create', [
    'sEmail' => 'customer@company.com',
    'tNote' => 'testing',
    'xCategory' => 1
]);

Update a request using the private api

$helpspot = new helpspot('https://company.helpspot.com', 'user@example.com', 'password');

$helpspot->post('private.request.update', [
    'xRequest' => 12400,
    'fNoteType' => 1, // A public note
    'tNote' => 'Update the request with this note.',
]);

Get a request using the private api

$helpspot = new helpspot('https://company.helpspot.com', 'user@example.com', 'password');

$request = $helpspot->get('private.request.get', [
    'xRequest' => 12400
]);

echo $request->sEmail;

Create a request using the public api

$helpspot = new helpspot('https://company.helpspot.com');

$helpspot->post('request.create', [
    'sEmail' => 'customer@company.com',
    'tNote' => 'testing'
]);

Checking for errors

$helpspot = new helpspot('https://company.helpspot.com', 'user@example.com', 'password');

$request = $helpspot->get('private.request.get', [
    'xRequest' => 12400
]);

if($helpspot->hasError())
{
    foreach($helpspot->getErrors() as $error)
    {
        echo $error->id .' '. $error->description;
    }
}
else
{
    echo $request->sEmail;
}

Security

If you discover any security related issues, please email customer.service@userscape.com instead of using the issue tracker.

Credits

  • UserScape Inc.

License

The MIT License (MIT). Please see License File for more information.