PHP code example of shubinmi / bamboohr-api

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

    

shubinmi / bamboohr-api example snippets




use BambooHRApi\services\BambooHrApi;

// Init Api
$api = new BambooHrApi('myCompanySubdomain', 'myApiKey');

// Get all employees
$employees = $api->getAllEmployees();
// Get additional information of each employee
$employees = $api->getMoreInfoForEmployees($employees, ['bestEmail', 'facebook']);

foreach ($employees as $employee) {
    echo 'Email: ' .$employee->workEmail . PHP_EOL;
    echo 'First name: ' .$employee->firstName . PHP_EOL;
    echo 'Last name: ' .$employee->lastName . PHP_EOL;
    echo 'Facebook: ' .$employee->facebook . PHP_EOL;
}



use BambooHRApi\api\EmployeesApi;
use BambooHRApi\BambooHrClient;
use BambooHRApi\conf\BambooHrConf;

// Init Api client
$conf = new BambooHrConf();
$conf->setApiKey('apiKey')
    ->setSubdomain('subdomain');
$client = new BambooHrClient($conf);

// Get all employees
$employees = EmployeesApi::getDirectoryEmployees($client);
// Get additional information of first employee
$firstEmployee = EmployeesApi::getEmployee($client, current($employees)->id, ['bestEmail', 'facebook']);

foreach ($employees as $employee) {
    echo 'Email: ' . $employee->workEmail . PHP_EOL;
    echo 'First name: ' . $employee->firstName . PHP_EOL;
    echo 'Last name: ' . $employee->lastName . PHP_EOL;
    echo 'Facebook: ' . $employee->facebook . PHP_EOL;
}

echo 'Best email: ' . $firstEmployee->bestEmail . PHP_EOL;
echo 'Facebook: ' . $firstEmployee->facebook . PHP_EOL;