Skip to content

Files

Latest commit

de136a6 · Jul 12, 2017

History

History
55 lines (38 loc) · 1.27 KB

README.md

File metadata and controls

55 lines (38 loc) · 1.27 KB

bexio API PHP Client

The bexio API Client Library enables you to work with the bexio API. This is an early version and is still in development.

See the bexio API documentation for more information how to use the API.

Installation

You can use Composer or download the library.

Require this package with composer:

composer require christianruhstaller/bexio-api-php-client

Include the autoloader:

require_once '/path/to/your-project/vendor/autoload.php';

Examples

Init client

    require_once '../vendor/autoload.php';
    
    $client = new \Bexio\Client([
        'clientId' => 'CLIENT_ID',
        'clientSecret' => 'CLIENT_SECRET',
    ]);
    
    $credentialsPath = 'PATH_TO_CREDENTIAL_FILE';
    
    if (!file_exists($credentialsPath)) {
        throw new \Exception('Credentials file not found for OAuth: '.$credentialsPath);
    }

    $accessToken = file_get_contents($credentialsPath);
    $client->setAccessToken($accessToken);

    if ($client->isAccessTokenExpired()) {
        $client->refreshToken($client->getRefreshToken());
        file_put_contents($credentialsPath, $client->getAccessToken());
    }

Get contacts

    $bexio = new Bexio($client);
    
    $contacts = $bexio->getContacts();