PHP code example of engageso / engage-php

1. Go to this page and download the library: Download engageso/engage-php 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/ */

    

engageso / engage-php example snippets


$engage = new \Engage\EngageClient($_SERVER['pub_key'], $_SERVER['pri_key']);

$engage->users->identify([
  'id' => 'u13345',
  'email' => '[email protected]',
  'created_at' => '2020-05-30T09:30:10Z'
]);

$engage->users->identify([
  'id' => 'u13345',
  'is_account' => true,
  'email' => '[email protected]',
  'created_at' => '2020-05-30T09:30:10Z'
]);

$engage->users->convertToAccount('u13345');

$engage->users->convertToCustomer('u15645');

$engage->users->addAttribute($userId, [
  'first_name' => 'Dan',
  'plan' => 'Premium'
]);

$engage->users->track($userId, 'Delinquent');

$engage->users->track($userId, [
  'event' => 'New badge',
  'value' => 'gold',
  'timestamp' => '2020-05-30T09:30:10Z'
]);

$engage->users->track($userId, [
  'event' => 'Add to cart',
  'properties' => [
    'product' => 'T123',
    'currency' => 'USD',
    'amount' => 12.99
  ]
]);

$engage->users->addToAccount($userId, $accountId, $role);

$engage->users->changeAccountRole($userId, $accountId, $newRole);

$engage->users->removeFromAccount($userId, $accountId);
ssh
composer