PHP code example of enhavo / cleverreach

1. Go to this page and download the library: Download enhavo/cleverreach library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

enhavo / cleverreach example snippets


use Enhavo\Component\CleverReach\ApiManager;
use Enhavo\Component\CleverReach\Http\SymfonyAdapter;

$adapter = new SymfonyAdapter();

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

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

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

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

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

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

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

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

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

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

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

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

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

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