PHP code example of obliosoftware / oblio-api
1. Go to this page and download the library: Download obliosoftware/oblio-api 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/ */
obliosoftware / oblio-api example snippets
try {
$issuerCif = ''; // your company CIF
$type = 'products'; // companies, vat_rates, products, clients, series, languages, management
$name = '';
$filters = [
'workStation' => '',
'management' => '',
'limitPerPage' => 250,
'offset' => 0,
];
$api = new OblioSoftware\Api($email, $secret);
$api->setCif($issuerCif);
$result = $api->nomenclature($type, $name, $filters);
} catch (Exception $e) {
// error handle
}
use OblioSoftware\AccessToken;
use OblioSoftware\AccessTokenHandlerInterface;
class CustomAccessTokenHandler implements AccessTokenHandlerInterface {
private $cacheKey = 'oblio_access_token';
public function get(): ?AccessToken
{
$data = Cache::get($this->cacheKey);
if ($data !== null) {
$accessToken = new AccessToken($data);
if ($accessToken && $accessToken->request_time + $accessToken->expires_in > time()) {
return $accessToken;
}
}
return null;
}
public function set(AccessToken $accessToken): void
{
Cache::set($this->cacheKey, $accessToken->toArray());
}
}
use OblioSoftware\Request\WebhookCreate;
try {
$issuerCif = ''; // your company CIF
$endpoint = ''; // a valid webhook endpoint
$api = new OblioSoftware\Api($email, $secret);
$response = $api->createRequest(
new WebhookCreate([
'cif' => $issuerCif,
'topic' => 'stock',
'endpoint' => $endpoint,
])
);
$result = json_decode($response->getBody()->getContents(), true);
} catch (Exception $e) {
// error handle
}