PHP code example of saccas / hitobito-json-api-model

1. Go to this page and download the library: Download saccas/hitobito-json-api-model 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/ */

    

saccas / hitobito-json-api-model example snippets



eUri = 'https://sac-cas.puzzle.ch';
$defaultHeaders = [
    'X-TOKEN' => '…',
];

$hitobitoApi = new \Saccas\HitobitoApi\HitobitoApi(new \GuzzleHttp\Client(), $baseUri, $defaultHeaders);
$coursesRepository = $hitobitoApi->getCoursesRepository();
$allCourses = $coursesRepository->getAll();
foreach($allCourses as $course) {
    echo $course->getId() . ' ' . $course->getName() . "\n";
    echo 'Location: ' . $course->getLocation() . "\n";
    echo 'Start: ' . $course->getDates()->get(0)->getStartAt()->format('Y-m-d') . "\n";
    $contact = $course->getContact();
    if (isset($contact)) {
        echo 'Contact: ' . $contact->getFirstName() . ' ' . $contact->getLastName() . "\n";
    }
    echo 'Accommodation: ' . $course->getAccommodation() . "\n";
    echo "\n";
}