-
Notifications
You must be signed in to change notification settings - Fork 16
/
ccf.php
29 lines (26 loc) · 971 Bytes
/
ccf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$cid = 'Your client ID from user settings';
$cs = 'Your client secret from user settings';
include_once 'v2/iDoklad.php';
use malcanek\iDoklad\iDoklad;
use malcanek\iDoklad\auth\iDokladCredentials;
use malcanek\iDoklad\iDokladException;
try{
$iDoklad = new iDoklad($cid, $cs, '');
$iDoklad->setCredentialsCallback(function($credentials){
file_put_contents('credentials.json', $credentials->toJson());
});
if(!file_exists('credentials.json')){
$iDoklad->authCCF();
}
$credentials = new iDokladCredentials(file_get_contents('credentials.json'), true);
$iDoklad->setCredentials($credentials);
$request = new \malcanek\iDoklad\request\iDokladRequest('IssuedInvoices');
$response = $iDoklad->sendRequest($request);
echo '<pre>';
print_r($response);
echo '</pre>';
} catch (iDokladException $ex) {
echo $ex->getMessage();
echo $ex->getTraceAsString();
}