daycry / zoom
Zoom 客户端 OAuth2
v1.1.0
2020-04-13 14:01 UTC
Requires
- php: >=7.2
- league/oauth2-client: ^2.4
README
Zoom
Codeigniter 4 的 Zoom API
通过 composer 安装
使用 composer install 安装此包
> composer require daycry/zoom
手动安装
下载此仓库,然后通过编辑 app/Config/Autoload.php 并将 Daycry\Zoom 命名空间添加到 $psr4 数组中来启用它。例如,如果您将其复制到 app/ThirdParty
$psr4 = [ 'Config' => APPPATH . 'Config', APP_NAMESPACE => APPPATH, 'App' => APPPATH, 'Daycry\Zoom' => APPPATH .'ThirdParty/zoom/src', ];
配置
运行命令
> php spark zoom:publish
此命令将配置文件复制到您的应用命名空间。
使用库
$zoom = new \Daycry\Zoom\Zoom();
作为服务使用
$zoom = \Config\Services::zoom();
作为辅助工具使用
在您的 BaseController - $helpers 数组中,添加一个包含您的辅助工具文件名的元素。
protected $helpers = [ 'zoom_helper' ];
然后,您可以使用此辅助工具
$zoom = zoom_instance();
身份验证
/** * * @return AccessTokenInterface */ $zoom = new \Daycry\Zoom\Zoom(); $token = $zoom->authentication(); echo "<pre>"; echo json_encode( $token ); echo "</pre>";
请求
/** * Returns an authenticated PSR-7 request instance. * * @param string $method * @param string $url * @return RequestInterface */ $zoom = new \Daycry\Zoom\Zoom(); $zoom->setAccessToken( $token ); $reponse = $zoom->request( 'GET', 'users' ); echo "<pre>"; var_dump( $reponse ); echo "</pre>";
您可以在请求方法中传递额外的参数。
/** * Returns an authenticated PSR-7 request instance. * * @param string $method * @param string $url * @param array $options Any of "headers", "body", and "protocolVersion". * @param AccessTokenInterface|string $token * @return RequestInterface */ $zoom = new \Daycry\Zoom\Zoom(); $zoom->setAccessToken( $token ); $reponse = $zoom->request( 'GET', 'users', [], $token ); echo "<pre>"; var_dump( $reponse ); echo "</pre>";
刷新令牌
/** * * @return AccessTokenInterface */ $zoom = new \Daycry\Zoom\Zoom(); $zoom->setAccessToken( $token ); $reponse = $zoom->refreshAccessToken(); echo "<pre>"; var_dump( $reponse ); echo "</pre>";
示例令牌以保存到数据库中
{"token_type":"bearer","scope":"dashboard_crc:read:admin","access_token":"xxxxx","refresh_token":"xxxxxx","expires":1586716974}
示例代码
示例.