2017 © Pedro Peláez
 

library hf-api-client

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

image

plhw/hf-api-client

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  • Sunday, March 11, 2018
  • by bushbaby
  • Repository
  • 1 Watchers
  • 0 Stars
  • 270 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 16 Versions
  • 0 % Grown

The README.md

PLHW Api Client

PLHW API Client provides means to authenticate clients against our OAuth2 server and issue authorized requests to our api endpoints., (*1)

Installation

composer require plhw/hf-api-client

Example API calls

Once you have succesfully installed the application, some example scripts are located at. To use them first copy an configuration file to your app root., (*2)

cp ./vendor/plhw/hf-api-client/example/.hf-api-client-secrets.php.dist ./.hf-api-client-secrets.php

Open .hf-api-client-secrets.php and configure it with credentials you got from us., (*3)

Finally the example scripts are configured to use data/cache as directory for its cached accss tokens. This directory must exist (only for the examples)., (*4)

Now you can run the example scripts;, (*5)

php ./vendor/plhw/hf-api-client/example/practicesPos.php

Usage

To implement usage in your application you can have a look at the example scripts., (*6)

$options = \HF\ApiClient\Options\Options::fromArray(
    [
        'server_uri'    => 'https://api.plhw.nl',
        'client_id'     => 'id',
        'client_secret' => 'secret',    
        'scope'         => 'customer_pos',
        'grant_type'    => 'client_credentials',
    ]
);

$api = \HF\ApiClient\ApiClient::createClient($options, /* $cache OPTIONAL */);

The above is all that is nessesary to configure, though I recommend you tweak the caching meganism. Currently we use the zendframework/zend-cache component. This might change when v3 is released to use the psr-7 caching FIG standard., (*7)

When you have ApiClient instance you can use it by calling methods as defined in /vendor/plhw/hf-api-client/data/v1 on it. Additionally API documentation can be found here., (*8)

for example, search the published practices around a coordinate., (*9)

$results = $api->customer_posAroundCoordinate('52.3629882,4.8593175', 15000, 'insoles');

if ($api->isSuccess()) {
    foreach ($results['data'] as $result) {
        printf("Practice %s on %skm\n", $result['attributes']['name'],
            round(($result['attributes']['distance'] / 100)) / 10);
        printf(" - sells %s\n", implode(', ', $result['attributes']['products']));
    }
} else {
    printf("Error (%d): %s\n", $api->getStatusCode(), $result);
}

Under the hood

When you call any method on the APIClient instance an access token is requested from our OAuth2 server. This access token is then cached for aditional uses up to the moment it expires or is deleted. It will then get a new access token., (*10)

Any calls to our API are now signed with that access token and is used by our permission system to determain if you have access or not., (*11)

Our API will accept and return json payload with are automaticly (de)encoded., (*12)

OAuth2 ClientCredentialsGrant

For machine to machine communication OAuth2 ClientCredentialGrant is appropiate. You must obtain the following information from us., (*13)

  1. client ID
  2. client secret
  3. scope

Your client side application should communicate via a proxy to our server., (*14)



[webbrowser] <----- internet -----> [application] <----- internet -----> [api.plhw.nl] 1. request data -> request -> do we have valid access token? 2. NO, get access token -> request -> id,secret,scope 3. validate request 4. store token in cache <- response <- access token 5. YES, request & token. -> request -> validate token 6. data <- response <- data 7. data <- response <- data

Run all examples in the 'commerce' domain:, (*15)

find ./example/commerce/ -maxdepth 1 -type f -exec {} \;

Upgrading

v2 has been rewritten for php 8+. Principals are the same but there are a few minor changes that will break your application., (*16)

Please see our examples to see how you interact with the api., (*17)

The Versions

11/03 2018

dev-master

9999999-dev

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

11/03 2018

1.0.0-beta10

1.0.0.0-beta10

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

10/03 2018

1.0.0-beta9

1.0.0.0-beta9

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

10/01 2018

1.0.0-beta8

1.0.0.0-beta8

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

09/06 2017

1.0.0-beta7

1.0.0.0-beta7

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

01/06 2017

1.0.0-beta6

1.0.0.0-beta6

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

01/06 2017

1.0.0-beta5

1.0.0.0-beta5

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

30/05 2017

1.0.0-beta4

1.0.0.0-beta4

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

04/05 2017

1.0.0-beta3

1.0.0.0-beta3

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

02/05 2017

1.0.0-beta2

1.0.0.0-beta2

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

26/04 2017

1.0.0-beta1

1.0.0.0-beta1

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

26/04 2017

0.2.3

0.2.3.0

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

19/04 2017

0.2.2

0.2.2.0

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

03/03 2017

0.2.1

0.2.1.0

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

28/02 2017

0.2.0

0.2.0.0

PLHW API Client provides means to authenticate clients against with OAuth2 server and issue authorized requests to our api endpoints

  Sources   Download

proprietary

The Requires

 

The Development Requires

26/02 2017

0.1.0

0.1.0.0

Provides means to obtain token from our OAuth2 server

  Sources   Download

proprietary

The Requires

 

The Development Requires