This library makes it easy to interact with the CleverReach REST API v3.
Switch branches/tags
Clone or download
Latest commit 2b9f7c2 Nov 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Update http adapter Nov 19, 2018
tests Optimize logging and minor bug fixes Nov 1, 2018
.env.dist Initial commit Oct 18, 2018
.gitignore Initial commit Oct 18, 2018
LICENSE Initial commit Oct 18, 2018
README.md Update README.md Oct 21, 2018
composer.json Initial commit Oct 18, 2018
phpunit.xml.dist Optimize logging and minor bug fixes Nov 1, 2018

README.md

CleverReach REST API v3 client

This library makes it easy to interact with the CleverReach REST API v3.

Installation

composer require rdoepner/cleverreach

Usage

Get an access token

use rdoepner\CleverReach\ApiManager;
use rdoepner\CleverReach\Http\Guzzle as HttpAdapter;

// Create an HTTP adapter
$httpAdapter = new HttpAdapter();

// Authorize your app by credentials
$response = $httpAdapter->authorize('<CLIENT_ID>', '<CLIENT_SECRET>');

if (isset($response['access_token'])) {
    // Persist the access token for later use...
}

Initialize an API manager

use rdoepner\CleverReach\ApiManager;
use rdoepner\CleverReach\Http\Guzzle as HttpAdapter;

// Create an HTTP adapter
$httpAdapter = new HttpAdapter(
    [
        'access_token' => '<ACCESS_TOKEN>',
    ]
);

// Create the API manager
$apiManager = new ApiManager($httpAdapter);

Create an inactive subscriber

$response = $apiManager->createSubscriber(
    '<EMAIL>',
    '<GROUP_ID>',
    false, // not activated
    [
        'salutation' => 'Mr.',
        'firstname' => 'John',
        'lastname' => 'Doe',
    ]
);

if (isset($response['id'])) {
    // ...
}

Trigger Double-Opt-In email for an inactive subscriber

$response = $apiManager->triggerDoubleOptInEmail('<EMAIL>', '<FORM_ID>');

if (isset($response['success'])) {
    // ...
}

Trigger Double-Opt-Out email for an active subscriber

$response = $apiManager->triggerDoubleOptOutEmail('<EMAIL>', '<FORM_ID>');

if (isset($response['success'])) {
    // ...
}

Get subscriber

$response = $apiManager->getSubscriber('<EMAIL>', '<GROUP_ID>');

if (isset($response['id'])) {
    // ...
}

Set active status of a subscriber

$response = $apiManager->getSubscriber('<EMAIL>', '<GROUP_ID>', '<TRUE_OR_FALSE>');

if (true === $response) {
    // ...
}

Delete subscriber

$response = $apiManager->deleteSubscriber('<EMAIL>', '<GROUP_ID>');

if (true === $response) {
    // ...
}