1. Go to this page and download the library: Download beriyack/jamfapi 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/ */
beriyack / jamfapi example snippets
yack\Jamf\JamfApiClient;
eriyack\Jamf\JamfApiClient;
use Exception;
// Vos identifiants Jamf
$networkId = 'VOTRE_NETWORK_ID'; // Remplacez par votre Network ID Jamf
$key = 'VOTRE_CLE_API'; // Remplacez par votre clé d'API Jamf
// Optionnel : Chemin vers votre certificat CA pour un environnement de développement local.
// Laissez `null` si vous êtes en production ou si votre système a déjà les bons certificats.
$caCertPath = __DIR__ . '/path/to/your/Amazon Root CA 1.crt';
try {
// Instanciez le client Jamf
// Le constructeur vérifiera si le fichier de certificat existe.
$jamf = new JamfApiClient($networkId, $key, $caCertPath);
// --- Exemple 1: Récupérer toutes les applications ---
echo "Récupération des applications...\n";
$apps = $jamf->getApps();
print_r($apps);
echo "\n";
// --- Exemple 2: Récupérer tous les appareils ---
echo "Récupération des appareils...\n";
$devices = $jamf->getDevices();
print_r($devices);
} catch (Exception $e) {
echo "Une erreur est survenue : " . $e->getMessage() . "\n";
}
try {
// Créer une nouvelle ressource (ex: un appareil)
$newDeviceData = ['name' => 'Nouveau iPad', 'asset_tag' => '12345'];
$createdDevice = $jamf->post('/devices', $newDeviceData);
echo "Appareil créé avec l'ID : " . $createdDevice['id'] . "\n";
// Mettre à jour cette ressource
$updatedData = ['name' => 'iPad de la salle de conférence'];
$jamf->put('/devices/' . $createdDevice['id'], $updatedData);
echo "Appareil mis à jour.\n";
// Supprimer la ressource
$jamf->delete('/devices/' . $createdDevice['id']);
echo "Appareil supprimé.\n";
} catch (Exception $e) {
echo "Une erreur CRUD est survenue : " . $e->getMessage() . "\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.