SDK for PHP
# Installation
# Repository
You can find SDK code in our public repository in here (opens new window).
# Composer
To install the via Composer (opens new window), run composer require docplanner/integrations-api-sdk-php
.
# Manual Installation
Download the files from repository and include autoload.php
:
require_once('/path/to/DocPlanner/Client/vendor/autoload.php');
# Authorization
To get access to API you need to make request to https://www.{domain}/oauth/v2/token
for access token using your client credentials (client_id
and client_secret
).
Then it could be injected to Configuration
which is used to instantiate API clients.
Whole authorization process is based on OAuth2 protocol with grant_type = client_credentials
and scope = integration
.
Obtained token is valid for the next 24h, so it is good practice to cache it for that period of time.
This can be done using our SDK:
//Get OAuth2 access token
$authorization = new DocPlanner\Client\Authorization('https://www.{domain}/oauth/v2/token');
$accessToken = $authorization->getAccessToken('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
// Configure access token for authorization
$config = DocPlanner\Client\Configuration::getDefaultConfiguration()->setAccessToken($accessToken);
$apiInstance = new DocPlanner\Client\Api\AddressesApi(null, $config);
# Example usage
Below you will find example of how you can use SDK
<?php
require_once(__DIR__ . '/vendor/autoload.php');
//Get OAuth2 access token
$authorization = new DocPlanner\Client\Authorization('https://www.{domain}/oauth/v2/token');
$accessToken = $authorization->getAccessToken('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
// Configure access token for authorization
$config = DocPlanner\Client\Configuration::getDefaultConfiguration();
$config->setAccessToken($accessToken);
$config->setHost('https://www.{domain}/api/v3/integration');
$doctorsApiInstance = new DocPlanner\Client\Api\DoctorsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$facilityId = 56; // int | ID of the Facility
$with = array(\DocPlanner\Client\Model\DoctorsScopes::SPECIALIZATIONS); // string[] |
try {
$result = $doctorsApiInstance->getDoctors($facilityId, $with);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DoctorsApi->getDoctors: ', $e->getMessage(), PHP_EOL;
}
$addressesApiInstance = new DocPlanner\Client\Api\AddressesApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$doctorId = 56; // int | ID of a doctor in a facility
try {
$result = $addressesApiInstance->getAddresses($facilityId, $doctorId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->getAddresses: ', $e->getMessage(), PHP_EOL;
}
?>