PHP code example of usebila / bila

1. Go to this page and download the library: Download usebila/bila 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/ */

    

usebila / bila example snippets




use Bila\Client;

$client = new Client(
  apiKey: getenv('BILA_API_KEY') ?: 'My API Key', environment: 'sandbox'
);

$accounts = $client->accounts->list();

var_dump($accounts->message);



use Bila\Core\Exceptions\APIConnectionException;
use Bila\Core\Exceptions\RateLimitException;
use Bila\Core\Exceptions\APIStatusException;

try {
  $accounts = $client->accounts->list();
} catch (APIConnectionException $e) {
  echo "The server could not be reached", PHP_EOL;
  var_dump($e->getPrevious());
} catch (RateLimitException $e) {
  echo "A 429 status code was received; we should back off a bit.", PHP_EOL;
} catch (APIStatusException $e) {
  echo "Another non-200-range status code was received", PHP_EOL;
  echo $e->getMessage();
}



use Bila\Client;

// Configure the default for all requests:
$client = new Client(requestOptions: ['maxRetries' => 0]);

// Or, configure per-request:
$result = $client->accounts->list(requestOptions: ['maxRetries' => 5]);



$accounts = $client->accounts->list(
  requestOptions: [
    'extraQueryParams' => ['my_query_parameter' => 'value'],
    'extraBodyParams' => ['my_body_parameter' => 'value'],
    'extraHeaders' => ['my-header' => 'value'],
  ],
);



$response = $client->request(
  method: "post",
  path: '/undocumented/endpoint',
  query: ['dog' => 'woof'],
  headers: ['useful-header' => 'interesting-value'],
  body: ['hello' => 'world']
);
sh
composer install
php examples/accounts.php