openprovider / rest-client-php
HTTP client for Openprovider API
Installs: 14 622
Dependents: 1
Suggesters: 0
Security: 0
Stars: 10
Watchers: 11
Forks: 9
Open Issues: 4
Requires
- php: >=7.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.4
This package is auto-updated.
Last update: 2024-10-27 16:32:28 UTC
README
PHP client for Openprovider API
Description
This software is a PHP client to operate with the Openprovider API.
At this time the API is stable enough to be used, however please note that during the beta phase we may still make breaking changes.
Please use v1beta branch/version.
Usage
- If you do not have composer.json in your project folder, create it with the command
composer init
- Set composer minimum stability to
dev
composer config minimum-stability dev
- Include this package as any other PHP library:
composer require openprovider/rest-client-php:dev-v1beta
- Access API via the
Client
class:<?php // Include autoloader. require __DIR__ . '/vendor/autoload.php'; use Openprovider\Api\Rest\Client\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);
- Check the ./examples directory for more complex examples.