1. Go to this page and download the library: Download crademaker/bexio-api-client 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/ */
crademaker / bexio-api-client example snippets
declare(strict_types=1);
use Crademaker\BexioApiClient\Auth\StaticTokenProvider;
use Crademaker\BexioApiClient\Http\BexioClient;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\HttpFactory;
$httpClient = new GuzzleClient();
$httpFactory = new HttpFactory();
$client = new BexioClient(
$httpClient,
$httpFactory,
$httpFactory,
new StaticTokenProvider('your-personal-access-token'),
);
$contacts = $client->contacts()->v2ListContacts([
'limit' => 20,
]);
declare(strict_types=1);
use Crademaker\BexioApiClient\Auth\InMemoryTokenStore;
use Crademaker\BexioApiClient\Auth\OAuthTokenService;
use Crademaker\BexioApiClient\Auth\RefreshableTokenProvider;
use Crademaker\BexioApiClient\Auth\TokenSet;
use Crademaker\BexioApiClient\Http\BexioClient;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\HttpFactory;
$httpClient = new GuzzleClient();
$httpFactory = new HttpFactory();
$tokenStore = new InMemoryTokenStore(
new TokenSet(
accessToken: 'initial-access-token',
refreshToken: 'refresh-token',
),
);
$oauth = new OAuthTokenService($httpClient, $httpFactory, $httpFactory);
$provider = new RefreshableTokenProvider(
clientId: 'client-id',
clientSecret: 'client-secret',
tokenStore: $tokenStore,
tokenService: $oauth,
scopes: ['openid', 'offline_access', 'contact_show'],
);
$client = new BexioClient($httpClient, $httpFactory, $httpFactory, $provider);