PHP code example of jaam / mixpanel-data-export-api

1. Go to this page and download the library: Download jaam/mixpanel-data-export-api 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/ */

    

jaam / mixpanel-data-export-api example snippets




aam\Mixpanel\DataExportApi;
use Jaam\Mixpanel\DataExportApiException;

$mixpanel = new DataExportApi('YOUR SECRET'); // Secret located in Mixpanel project settings

// Perform setup, as above
try {
    // Retrieve events from `events` endpoint
    $data = $mixpanel->data('events', [
        'event' => ['event_name'], // Array of event names
        'type' => 'unique',
        'unit' => 'day',
        'from_date' => '2016-12-01',
        'to_date' => '2016-12-31'
    ]);

    // $data is an array
} catch ( DataExportApiException $e )
    // Handle exception
}

// Perform setup, as above
try {
    // Export raw data
    $data = $mixpanel->export([
        'from_date' => '2016-12-01',
        'to_date' => '2016-12-31'
    ]);

    // $data is an array
} catch ( DataExportApiException $e )
    // Handle exception
}

// Bootstrap Silex app

use Jaam\Mixpanel\Integration\Silex\MixpanelDataExportProvider;

$app['mixpanel.api_secret'] = 'YOUR SECRET'; // Secret located in Mixpanel project settings
$app->register(new MixpanelDataExportProvider);

// Use via `mixpanel.api` server later in application
$data = $app['mixpanel.api']->export([
    'from_date' => '2016-12-14',
    'to_date' => '2016-12-18'
]);