PHP code example of samaphp / desktime
1. Go to this page and download the library: Download samaphp/desktime 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/ */
samaphp / desktime example snippets
$Account = new Account();
$Account->setCredentials(['api_key' => 'API_KEY_HERE']);
$company = $Account->company();
print_r($company);
stdClass Object
(
[pass] => 1
[code] => 200
[body] => stdClass Object
(
[name] => Company name
[work_starts] => 07:15:00
[work_ends] => 18:00:00
[work_duration] => 28800
[working_days] => 79
[work_start_tracking] => 07:00:00
[work_stop_tracking] => 22:45:00
[timezone_identifier] => Asia/Riyadh
[__request_time] => 1578933311
)
)
$Employee = new Employee();
$Employee->setCredentials(['api_key' => 'API_KEY_HERE']);
// Getting all employees.
// $all = $Employee->all(['date' => '2019-11-13', 'period' => 'month']); //.
$all_employees = $Employee->all();
print_r($all_employees);
// Getting current employee. (the owner of this API key)
$current_employee = $Employee->get();
print_r($current_employee);
// Load employee data by his Desktime email.
$email = '[email protected]';
$employee = $Employee->getEmployeeByEmail($email);
print_r($employee);