diff --git a/example/example.php b/example/example.php new file mode 100644 index 0000000..359e892 --- /dev/null +++ b/example/example.php @@ -0,0 +1,63 @@ +initSessionByCredentials('glpi', 'glpi'); +} catch (Exception $e) { + // print the error if failed + echo $e->getMessage(); + die(); +} + +// Let's make a request to an End Point +$endPointHandler = new \Glpi\Api\Rest\EndPointHandler($client); +$response = $endPointHandler->getMyProfiles(); +$profiles = json_decode($response['body']); +foreach ($profiles->myprofiles as $profile) { + echo "Profile name: " . $profile->name . "\n"; +} + +// Let's work with item types +$itemHandler = new \Glpi\Api\Rest\ItemHandler($client); +$response = $itemHandler->getAnItem('User', 2); +$bodyDecoded = json_decode($response['body']); +if ($response['statusCode'] == 404) { + // User not found + die($bodyDecoded[1]); +} +echo "User name: " . $bodyDecoded->name . "\n"; + +// let's end the session. +$client->killSession(); \ No newline at end of file