silinternational / idp-id-broker-php-client
PHP 客户端,用于与我们的 IdP ID Broker API 交互:https://github.com/silinternational/idp-id-broker
4.4.0
2024-09-20 07:27 UTC
Requires
- php: >=7.4
- guzzlehttp/guzzle-services: ^1.1
- mlocati/ip-lib: ^1.14
- roave/security-advisories: dev-master
Requires (Dev)
- behat/behat: ^3.3
- phpunit/phpunit: ^8.0
README
PHP 客户端,用于与我们的 IdP ID Broker API 交互。
此客户端基于 Guzzle 构建,Guzzle 是 PHP HTTP 客户端。Guzzle 提供了一种简单的方式来创建 API 客户端,通过使用类似 Swagger 的格式描述 API,无需自行实现每个方法。因此,支持更多 API 相对简单。
安装
使用 Composer 进行安装非常简单
$ composer require silinternational/idp-id-broker-php-client
用法
示例
<?php use Sil\Idp\IdBroker\Client\IdBrokerClient; $idBrokerClient = new IdBrokerClient( 'https://api.example.com/', // The base URI for the API. 'DummyAccessToken', // Your HTTP header authorization bearer token. [ 'http_client_options' => [ 'timeout' => 10, // An (optional) custom HTTP timeout, in seconds. ], ] ); $users = $idBrokerClient->listUsers();
用户信息
此客户端返回的用户信息(例如通过 getUser(...)
)可以包括以下字段
employee_id
(字符串)first_name
(字符串)last_name
(字符串)display_name
(字符串)username
(字符串)email
(字符串)active
(字符串:'yes' 或 'no')locked
(字符串:'yes' 或 'no')
测试
要运行此单元测试,请运行 make test
。
Guzzle 服务客户端说明
- 关于使用 Guzzle Web Services 开发 API 客户端的教程
http://www.phillipshipley.com/2015/04/creating-a-php-nexmo-api-client-using-guzzle-web-service-client-part-1/ - Jeremy Lindblom 的演示
https://speakerdeck.com/jeremeamia/building-web-service-clients-with-guzzle-1 - Jeremy Lindblom 的示例
https://github.com/jeremeamia/sunshinephp-guzzle-examples - 源代码注释中的参数文档
https://github.com/guzzle/guzzle-services/blob/master/src/Parameter.php - Guzzle 3 服务描述文档(至少大部分仍相关)
https://guzzle3.readthedocs.org/webservice-client/guzzle-service-descriptions.html