shiftplanning/humanity-php-sdk
最新稳定版本:1.1.8
Composer 安装命令:
composer require shiftplanning/humanity-php-sdk
包简介
Humanity PHP SDK
README 文档
README
Installation
Install the latest version with
$ composer require shiftplanning/humanity-php-sdk
Usage
Initialize
Make sure to loade composer autoload file.
<?php use \Humanity\Entity\Company; use \Humanity\Entity\Employee; use \Humanity\Humanity; // Load Humanity SDK for PHP via composer $config = [ 'provider' => [ 'clientId' => '...', 'clientSecret' => '...', 'redirectUri' => '...', 'scopes' => [ Company::SCOPE_VIEW, Employee::SCOPE_VIEW ], ], ]; // Create new instance of humanity class $humanity = new Humanity($config);
Obtain access token
Obtained access token will be saved for you in _SESSION variable.
// Obtain access token $humanity->obtainAccessToken(); // Get access token instance $accessToken = $humanity->getAccessToken(); printf('Access token: %s<br/>', $accessToken->accessToken);
Retrive logged employee data
Invoking Humanity::me() will return Employee entity instance
$me = $humanity->me(); printf('Hello, %s<br/>', $me->display_name);
Working with entities
Retrieve data
// Get Company repository instance $companyRepository = $humanity->getCompanyRepository(); // Retrieve company data for current logged employee $company = $companyRepository->get($me->company_id); printf('Company: %s<br/>', $company->name); // Get Employee repository instance $employeeRepository = $humanity->getEmployeeRepository(); // Retrieve employees data for company. $employees = $employeeRepository->getByCompany($company->company_id); echo 'Employees: '; echo '<ul>'; // Iterating employees collection foreach ($employees as $employee) { printf('<li>%s</li>', $employee->display_name); } echo '</ul>';
统计信息
- 总下载量: 5.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-19