PHP code example of th3mouk / reactive-klaviyo

1. Go to this page and download the library: Download th3mouk/reactive-klaviyo 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/ */

    

th3mouk / reactive-klaviyo example snippets


use Clue\React\Buzz\Browser as ClueBrowser;
use Rxnet\HttpClient\Browser as RxBrowser;

$clue = new ClueBrowser(EventLoop::getLoop());
$httpClient = new RxBrowser($clue);

$client = new Client('klaviyo-api-token', $httpClient);

$payload = Payload::create('event-name')
    ->addCustomerProperty(Property::create('$email', '[email protected]'))
    ->addCustomerProperty(Property::create('$id', 'uuid-or-whatever'))
    ->addProperty(Property::create('lang', 'fr'))
    ->addProperty(Property::create('amount', 56))
    ->definePastEventDate(1559722012)
;

$client->track(Payload $payload)
$client->trackOnce(Payload $payload)