This action lets you reject an incoming call without incurring any usage charges from our APIs. Note that this should be the only element in your response.


Sample PHP Implementation

Assuming that you have configured the callback URL for your Africa's Talking Phone Number to point to handleCalls.php. Below is an example of how you can reject black-listed phone numbers that dial into your phone number.

// Save this code in handleCalls.php. Configure the callback URL for your phone number
// to point to the location of this script on the web
// e.g

// First read a couple of the POST variables passed in with the request

// This is a unique ID generated for this call
$sessionId = $_POST['sessionId'];

// Check to see whether this call is active
$isActive  = $_POST['isActive'];

// Here is our black-listed numbers
$blackListArr = array('+254711XYZXYZ');

if ($isActive == 1)  {
  // Check whether this is the caller that has been giving you
  // sleepless nights
  $callerNumber = $_POST['callerNumber'];
  if ( in_array($callerNumber, $blackListArr) ) {
    // Compose the rejection response  
    $response  = '<?xml version="1.0" encoding="UTF-8"?>';
    $response .= '<Response>';
    $response .= '<Reject/>';
    $response .= '</Response>';
  } else {    
    // Your regular application logic goes here
    $response  = '<?xml version="1.0" encoding="UTF-8"?>';
    $response .= '<Response>';
    $response .= '<Say>Hello world</Say>';
    $response .= '</Response>';    
  // Print the response onto the page so that our gateway can read it
  header('Content-type: text/plain');
  echo $response;

} else {
  // Read in call details (duration, cost). This flag is set once the call is completed.
  // Note that the gateway does not expect a response in thie case
  $duration     = $_POST['durationInSeconds'];
  $currencyCode = $_POST['currencyCode'];
  $amount       = $_POST['amount'];
  // You can then store this information in the database for your records