PHP code example of open-resource-manager / client-php
1. Go to this page and download the library: Download open-resource-manager/client-php 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/ */
open-resource-manager / client-php example snippets
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);
}
}
}
shell
composer