PHP

Start integrating any APIs with the Bearer client for PHP

Installing & initializing

PHP
composer require bearer/bearer-php
PHP
# Initialize the client with your Bearer API key
$bearer = new Bearer\Client(BEARER_API_KEY);

Replace the BEARER_API_KEY respectively with your API Key and Encryption Key that can be found on your Developer Keys page.

Calling APIs

PHP
# GET call
$bearer
->integration('github')
->get('/repositories', ["query" => ["since" => 364 ]]);
# GET call with a custom SetupId
$bearer
->integration('github')
->setup(SETUP_ID)
->get('/repositories', ["query" => ["since" => 364 ]]);
# POST call with OAuth
$bearer
->integration('github')
->auth($authId)
->post('/user/repos', ["body" => ["name" => "Just setting up my Bearer.sh" ]]);
# GET call with a custom header
$bearer
->integration('github')
->setup(SETUP_ID)
->get('/repositories', ["headers" => ["Accept": "application/json"], "query" => ["since" => 364 ]]);

Behind the scene, we use the cURL extension for PHP. Thus, each request will return the output of a curl_exec.

Dive into the source code of the PHP client, to learn more about its structure.