Skip to main content

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.

Almost anything you can do through the CallFire user interface can also be done through CallFire APIs. This includes using CallFire to create SMS broadcasts, which you will learn how to do with a few PHP examples.

Assumptions

Before we get started, you will need a couple of things ...

  1. An API login and password from your CallFire account. If you don't have an API login, click here.
  2. Familiarity with PHP and REST concepts.

If we want to send a message, we simply need to provide our target phone number and the message itself ...


<?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'));

If we want to send a message, we simply need to provide our target phone number and the message itself ...


<php
$sendTextRequest = array(
  'BroadcastName' => 'Test SMS broadcast',
  'ToNumber'      => '18185551212',
  'TextBroadcastConfig' => array(
    'Message' => 'Hello, world!'));
$broadcastId = $client->sendText($sendTextRequest);
echo "New broadcast ID: $broadcastId\n";

If successful, CallFire will return the broadcast ID, which should be useful for getting information about the text campaign (e.g., how many credits were billed to our account). After we send the text message, we can wait a few seconds and then make the request for the broadcast statistics ...


sleep(15);
$stats = $client->getBroadcastStats(array('Id' => $broadcastId));
var_dump($stats);

When I ran the example, I found out that I was charged 0.03 credits for my text message ...


object(stdClass)#2 (2) {
  ["UsageStats"]=>
  object(stdClass)#3 (5) {
    ["Duration"]=>
    int(0)
    ["BilledDuration"]=>
    int(0)
    ["BilledAmount"]=>
    float(0.03)
    ["Attempts"]=>
    int(1)
    ["Actions"]=>
    int(1)
  }
  ["ResultStat"]=>
  object(stdClass)#4 (3) {
    ["Result"]=>
    string(4) "SENT"
    ["Attempts"]=>
    int(1)
    ["Actions"]=>
    int(1)
  }
}

If you want to send messages to more than one recipient, you can add comma-separated numbers to the to parameter in the initial request to https://www.callfire.com/api/rest/text/send (e.g., 'to' => '13105551212,18185551212,16265551212').


$sendTextRequest = array(
  'BroadcastName' => 'Test SMS broadcast',
  'ToNumber'      => array('18185551212','12135551212','12125551212'),
  'TextBroadcastConfig' => array(
    'Message' => 'Hello, world!'));
$broadcastId = $client->sendText($sendTextRequest);