GithubHelp home page GithubHelp logo

antoineveldhoven / rest-client-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openprovider/rest-client-php

0.0 0.0 2.0 742 KB

PHP client for Openprovider API

Home Page: https://docs.openprovider.com

PHP 100.00%

rest-client-php's Introduction

rest-client-php

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

  1. If you do not have composer.json in your project folder, create it with the command
    composer init
  2. Set composer minimum stability to dev
    composer config minimum-stability dev
  3. Include this package as any other PHP library:
    composer require openprovider/rest-client-php:dev-v1beta
  4. 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);
  5. Check the ./examples directory for more complex examples.

rest-client-php's People

Contributors

arkareth avatar eyudkin avatar dmirou avatar emdqueller avatar dandreev94 avatar slavamuravey avatar antoineveldhoven avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.