Skip to content

Instantly share code, notes, and snippets.

@agramonte
Last active March 14, 2021 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agramonte/d9f5f8fb3b635c5af629c2d5a93abf5b to your computer and use it in GitHub Desktop.
Save agramonte/d9f5f8fb3b635c5af629c2d5a93abf5b to your computer and use it in GitHub Desktop.
<?php
if( $_GET["api_key"] && ($_GET["user_id"] || $_GET["device_id"] ) && $_GET["event_type"] ) {
// Required data
$data = array(
'event_type' => $_GET['event_type']
);
if( $_GET["user_id"] ) {
$data['user_id'] = $_GET["user_id"];
}
if( $_GET["device_id"] ) {
$data['device_id'] = $_GET["device_id"];
}
if( $_GET["app_version"] ) {
$data['app_version'] = $_GET["app_version"];
}
if( $_GET["os_name"] ) {
$data['os_name'] = $_GET["os_name"];
}
if( $_GET["os_version"] ) {
$data['os_version'] = $_GET["os_version"];
}
if( $_GET["device_model"] ) {
$data['device_model'] = $_GET["device_model"];
}
if( $_GET["country"] ) {
$data['country'] = $_GET["country"];
}
if( $_GET["language"] ) {
$data['language'] = $_GET["language"];
}
$data2 = array(
'api_key' => $_GET["api_key"],
'events' => $data
);
$url = "https://api2.amplitude.com/2/httpapi";
$ch = curl_init($url);
$payload = json_encode($data2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment