open-resource-manager / client-php
ORM 客户端库,用于 PHP。
v1.2.0
2020-06-03 18:07 UTC
Requires
- php: >=5.4.0
- mashape/unirest-php: ^3.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-29 04:03:24 UTC
README
安装
使用 composer 安装。
composer require open-resource-manager/client-php ~1.0
用法
文档
API 文档可在 此处 查看。
示例
<?php use Exception; use OpenResourceManager\ORM; use OpenResourceManager\Client\Account as AccountClient; class SomeClass { function someFunction () { // API environment variables $apiSecret = '123456789'; $apiHost = 'localhost'; $apiPort = 80; $apiVersion = 1; $useHttps = false; // Build the ORM connection $orm = new ORM($apiSecret, $apiHost, $apiVersion, $apiPort, $useHttps); // Build an account client $accountClient = new AccountClient($orm); // Get an ORM Account $response = $accountClient->getFromUsername('skywal'); // Verify that the API returned a 200 http code if ($response->code == 200) { // Get the account from the response body $account = $response->body->data; } else { // Throw an exception if we did not get 200 back // display the http code with the message from the API. throw new Exception($response->body->message, $response->code); } } }