CallFire API v2.0 PHP SDK (beta)

Project page

Getting started


Before start you should add dependency to your composer json:

  "require": {
      "callfire/php-sdk": "^2.0"

Also you can find the latest bundle at releases page.

In case you want to build it yourself:

  $ git clone -b 2.0
  $ cd CallFire-PHP-SDK
  $ composer install

Please refer to the Composer intro if you are unfamiliar with this tool.


To create client instance just provide API login and password. API credentials should be configured on Account -> Settings -> API Access page. Client uses HTTPS connection and Basic Authentication.

This example demonstrates how to instantiate the REST API client, create a request object, invoke a request, and then parse the response into an easily-consumable form:

require 'vendor/autoload.php';

$client = \CallFire\Api\DocumentedClient::createClient("<api-login>", "<api-password>");
$request = $client->findCallBroadcasts();
$response = $client->request($request);
echo $response->getBody();

Code hints with examples: Api client methods hints with examples can be generated. Each method hint also includes code sample how to configure api request and what parameters are available. You'll be able to use that hints from ide for easier coding of your integration. To do that please run command:

    php src/CallFire/CodeHint/CodeHintsGenerator.php generateCodeHints swaggerJsonUrl

Note: swaggerJsonUrl parameter can be skipped - default path is "".

Error handling

The CallFire Developers API uses standard HTTP response codes for responses. These HTTP codes indicate whether or not an API operation is successful.

Status Code 200 is the desired response code. A standard JSON response will follow.

Codes in the 400s range detail all of the errors a CallFire Developer could encounter while using the API. Bad Request, Rate Limit Reached, and Unauthorized are some of the sorts of responses in the 400s block.

Codes in the 500s range are error responses from the CallFire system. If an error has occurred anywhere in the execution of a resource that was not due to user input, a 500 response will be returned with a corresponding JSON error body. In that body will contain a message detailing what went wrong.

Getting access to the HTTP response

The default behavior for all API calls is to return API entities like:

require 'vendor/autoload.php';

$client = \CallFire\Api\DocumentedClient::createClient("<api-login>", "<api-password>");
$request = $client->findCallBroadcasts();
$response = $client->request($request);
$json = json_decode($response->getBody());

Default request timeout

In api client default request timeout value equal to 10 seconds. But this can be programmatically changed like in example below:

require 'vendor/autoload.php';

$client = \CallFire\Api\DocumentedClient::createClient("<api-login>", "<api-password>");
$client->getHttpClient()->setOptions([ 'timeout' => 60 ]);

Debug & logging