1. Go to this page and download the library: Download readdle/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/ */
readdle / amplitude-php example snippets
use Readdle\AmplitudeClient\Amplitude;
use Readdle\AmplitudeClient\Model\HttpApiV2\Event;
use Readdle\AmplitudeClient\Model\IdentifyApi\Identification;
$apiKey = 'YOUR_AMPLITUDE_API_KEY';
$apiSecret = 'YOUR_AMPLITUDE_SECRET'; // optional for HTTP API v2 and Identify API
$amplitude = new Amplitude($apiKey, $apiSecret);
// 1) Send a single event (HTTP API v2)
$event = new Event();
$event->setUserId('user-123');
$event->setEventType('purchase');
$event->setRevenue(9.99);
$amplitude->httpApiV2->sendEvent($event);
// 2) Identify: set/update user properties
$identification = new Identification();
$identification->setUserId('user-123');
$identification->userProperties->set('prop1', 'value1');
$identification->userProperties->set('prop2', 'value2');
$amplitude->identifyApi->identify($identification);
// 3) User Privacy API: create a deletion job
$request = [
'user_ids' => ['user-123', 'user-456'],
// see Amplitude official docs for other fields
];
$amplitude->userPrivacyApi->deleteUsers($request);
// 4) User Profile API: fetch user properties
$profile = $amplitude->userProfileApi->getUserProperties('user-123');
print_r($profile->getBody());