crisp-im / php-crisp-api

:elephant: Crisp API PHP Wrapper
https://docs.crisp.chat/guides/rest-api/
MIT License
56 stars 28 forks source link

Crisp API PHP

Build and Release Version Downloads

The Crisp API PHP wrapper. Authenticate, send messages, fetch conversations, access your agent accounts from your PHP code.

Copyright 2023 Crisp IM SAS. See LICENSE for copying information.

Installation with composer

composer require crispchat/php-crisp-api

Authentication

To authenticate against the API, obtain your authentication token keypair by following the REST API Authentication guide. You'll get a token keypair made of 2 values.

Keep your token keypair values private, and store them safely for long-term use.

Then, add authentication parameters to your client instance right after you create it:

require __DIR__ . '/vendor/autoload.php';
$CrispClient = new \Crisp\CrispClient;

// Authenticate to API with your plugin token (identifier, key)
// eg. $CrispClient->authenticate("7c3ef21c-1e04-41ce-8c06-5605c346f73e", "cc29e1a5086e428fcc6a697d5837a66d82808e65c5cce006fbf2191ceea80a0a");
$CrispClient->setTier("plugin");
$CrispClient->authenticate(identifier, key);

// Now, you can use authenticated API sections.

API Overview

You may follow the REST API Quickstart guide, which will get you running with the REST API in minutes.

require __DIR__ . '/vendor/autoload.php';
$CrispClient = new \Crisp\CrispClient;

$CrispClient->setTier("plugin");
$CrispClient->authenticate(identifier, key);

$conversations = $CrispClient->websiteConversations->getList(websiteId, 1);
echo $conversations;

Available resources & methods

All the available Crisp API resources are fully implemented. Programmatic methods names are named after their label name in the REST API Reference.

All methods that you will most likely need when building a Crisp integration are prefixed with a star symbol (⭐).

Where you see params it is a plain Array object, e.g. [email => 'foo@example.com' ]

⚠️ Note that, depending on your authentication token tier, which is either user or plugin, you may not be allowed to use all methods from the library. When in doubt, refer to the library method descriptions below. Most likely, you are using a plugin token.

Website

👉 Notice: The peopleID argument can be an email or the peopleID.

Plugins