CallFire has a new API!

We are proud to announce the launch of our API 2.0! Learn more about our streamlined, transactional and broadcast APIs. This version of the API documentation will remain available for reference only. There will be no new development, only bug fixes. We highly recommend upgrading to our newer and more sophisticated documentation.

Sending a voice broadcast through CallFire’s user interface is easy. Integrating voice broadcast into your application through CallFire APIs is almost as easy.

Assumptions

  1. You have a CallFire API login and password. If you don't have an API login, click here.
  2. A knowledge of PHP.

Before starting, you'll need:

  • A sound file in WAV or MP3 format that you want to broadcast.
  • A validated caller ID to use as part of your campaign.
 

Sending a Voice Broadcast

Let’s say that we are building an application that we want to automatically upload a sound file and broadcast to a phone number using CallFire APIs. First, we will need to upload the sound file.

<?php
/*
 * You'll need your login/password pair when you create the SOAP
 * client. Don't use this one; it's just for show and won't work.
 */
$wsdl = "https://callfire.com/api/1.0/wsdl/callfire-service-http-soap12.wsdl";
$client = new SoapClient($wsdl, array(
   'soap_version' => SOAP_1_2,
   'login'        => '72f42300c1a1',    
   'password'     => '44261a4592146a63'));
/*
 * You’ll need to load your sound file in order to create the request.
 * MP3 is preferred, although we can also use some WAV formats.
 */
$soundData = file_get_contents('myNewSound.mp3'); 
$createSoundRequest = array(
    'Name' => 'My new sound',
    'Data' => $soundData);
$soundId = $client->createSound($createSoundRequest);
echo "New sound ID: $soundId\n";

If the API call $client->createSound() was successful, then it should have returned the unique CallFire ID for our new sound. Once we have the sound ID, we can start sending out phone calls.


/*
 * I’m using a single number here, although $toNumber could
 * also be an array(...) of phone numbers. 
 */
$toNumber   = '18185551212';
/* 
 * The $fromNumber is your caller ID. This will need to be 
 * verified with CallFire before you will be allowed to use it.
 */
$fromNumber = '13105551212';

$sendCallRequest = array(
  'ToNumber'             => $toNumber,
  'VoiceBroadcastConfig' => array(
    'FromNumber'             => $fromNumber,
    'AnsweringMachineConfig' => 'LIVE_IMMEDIATE',
    'BroadcastName'          => 'Example Broadcast',
    'LiveSoundId'            => $soundId
));

$broadcastId = $client->sendCall($sendCallRequest);
echo "Broadcast ID: $broadcastId\n";

Upon success, the $broadcastId variable should contain the broadcast ID, which you can use to grab information about the broadcast ...


$broadcastInfo = $client->getBroadcast(array('Id'=>$broadcastId));

However, the best way to keep track of how your calls are doing is to register a URL with our notification services, which you can do by emailing support@callfire.com.

Our final code should look like this ...
<?php
$wsdl = "https://callfire.com/api/1.0/wsdl/callfire-service-http-soap12.wsdl";
$client = new SoapClient($wsdl, array(
   'soap_version' => SOAP_1_2,
   'login'        => '72f42300c1a1',    
   'password'     => '44261a4592146a63'));
$soundData = file_get_contents('myNewSound.mp3'); 
$createSoundRequest = array(
    'Name' => 'My new sound',
    'Data' => $soundData);
$soundId = $client->createSound($createSoundRequest);
echo "New sound ID: $soundId\n";

$toNumber   = '18185551212';
$fromNumber = '13105551212';
$sendCallRequest = array(
  'ToNumber'             => $toNumber,
  'VoiceBroadcastConfig' => array(
    'FromNumber'             => $fromNumber,
    'AnsweringMachineConfig' => 'LIVE_IMMEDIATE',
    'BroadcastName'          => 'Example Broadcast',
    'LiveSoundId'            => $soundId
));

$broadcastId = $client->sendCall($sendCallRequest);
echo "Broadcast ID: $broadcastId\n";
$broadcastInfo = $client->getBroadcast(array('Id'=>$broadcastId));
?>