PHP code example of jacktrac / jacktrac-php

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

    

jacktrac / jacktrac-php example snippets



nitialize the JackTrac client
$client = new JackTrac\Client('JACKTRAC_URL');

try {
    // Specify the device ID for which you want to retrieve logs
    $device_id = 'DEVICE_ID';

    // Fetch logs for the specified device
    $devices = $client->get_device_logs('YOUR_TOKEN', $device_id)->data;

    // Output the logs
    foreach ($devices as $device) {
        foreach ($device->logs as $log) {
          echo $log->DateTime . "\n";
        }
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}
composer