PHP code example of intempt / intempt-php

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

    

intempt / intempt-php example snippets


use Intempt\Intempt;

$intempt = new Intempt([
    'org' => 'my-org',
    'project' => 'my-project',
    'apiKey' => getenv('INTEMPT_API_KEY'),   // "<prefix>.<secret>"
    'sourceId' => '684508596718616576',
]);

$intempt->track('purchase', [
    'userId' => '[email protected]',
    'properties' => ['total' => 99.99],
]);

$feed = $intempt->recommend([
    'userId' => '[email protected]',
    'feedId' => '5292',
    'fields' => ['id', 'title'],
]);

use Intempt\BatchOptions;

$intempt = new Intempt([
    // …
    'batch' => new BatchOptions(size: 50, flushMs: 5_000, maxQueue: 10_000),
]);
bash
composer