PHP code example of openprovider / rest-client-php
1. Go to this page and download the library: Download openprovider/rest-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/ */
openprovider / rest-client-php example snippets
// Include autoloader.
nt\Auth\Model\AuthLoginRequest;
use Openprovider\Api\Rest\Client\Base\Configuration;
use Openprovider\Api\Rest\Client\Client;
use GuzzleHttp\Client as HttpClient;
// Create new http client.
$httpClient = new HttpClient();
// Create new configuration.
$configuration = new Configuration();
// Build api client for using created client & configuration.
$client = new Client($httpClient, $configuration);
// Our credentials;
$username = 'user';
$password = 'pass';
// Retrieve token for further using.
$loginResult = $client->getAuthModule()->getAuthApi()->login(
new AuthLoginRequest([
'username' => $username,
'password' => $password,
])
);
// Set token to configuration (it will update the $client).
$configuration->setAccessToken($loginResult->getData()->getToken());
// Use this client for API calls.
$result = $client->getTldModule()->getTldServiceApi()->getTld('com');
// Operate with the result.
print_r($result);