PHP code example of laurynasgadl / amplitude-php

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

    

laurynasgadl / amplitude-php example snippets


use Luur\Amplitude\Amplitude;
use Luur\Amplitude\Event;

$amplitude = new Amplitude('api-key');

$event = new Event();
$event->user_id = '123456';
$event->event_type = 'test-event';

$result = $amplitude->send($event);

use Luur\Amplitude\Amplitude;
use Luur\Amplitude\Message;
use Luur\Amplitude\Event;

$amplitude = new Amplitude('api-key');

$event_1 = new Event([
    'user_id' => '123456',
    'event_type' => 'test-event',
]);

$event_2 = new Event([
    'user_id' => '987654',
    'event_type' => 'test-event',
]);

$message = new Message([
    $event_1,
    $event_2,
]);

$result = $amplitude->send($message);

use Luur\Amplitude\AmplitudeV2;
use Luur\Amplitude\Event;

$amplitude = new AmplitudeV2('api-key');

$event = new Event();
$event->user_id = '123456';
$event->event_type = 'test-event';

$result = $amplitude->send($event);