Number of queued calls

You need your AfricasTalking username and APIKey for any request to our API. If you don't have an APIKey, please click here to get one.

The PHP code snippet below shows how you can get number of queued calls of your Africas Talking phone number using our API.

The code uses our PHP gateway class: AfricasTalkingGateway.php [ Download]

Also, please ensure that you have the php_curl module enabled. To enable it uncomment the line: ;extension=php_curl.dll in php.ini and restart apache

<?php
// Be sure to include our gateway class
require_once('AfricasTalkingGateway.php');

// Specify your login credentials
$username   = "MyAfricasTalking_Username";
$apikey     = "MyAfricasTalking_APIKey";

// NOTE: If connecting to the sandbox, please use your sandbox login credentials	

// Specify your Africa's Talking phone number in international format
// Comma separate them if they are more than one
$phoneNumber = "+254711082XXX";

// Create a new instance of our awesome gateway class
$gateway = new AfricasTalkingGateway($username, $apikey);

// NOTE: If connecting to the sandbox, please add the sandbox flag to the constructor:
/*************************************************************************************
            ****SANDBOX****
$gateway    = new AfricasTalkingGateway($username, $apiKey, "sandbox");
**************************************************************************************/

// Any gateway errors will be captured by our custom Exception class below, 
// so wrap the call in a try-catch block
try 
{
  $results = $gateway->getNumQueuedCalls($phoneNumber);
  
  // For a specific queue, specify the queue name eg:
  // $queueName = "myQueueName"
  // $results = $gateway->getNumQueuedCalls($phoneNumber, $queueName);
  
  foreach($results as $result) {
   echo "Phone number: " . $result->phoneNumber . "; ";
   echo "Queue name: " . $result->queueName . "; ";
   echo "Number of queued calls: " . $result->numCalls . "<br/>";
  }
}
catch ( AfricasTalkingGatewayException $e )
{
  echo "Encountered an error while making the call: ".$e->getMessage();
}

// DONE!!! 

Our REST resource for getting the number of queued calls is located at: https://voice.africastalking.com/queueStatus. In order to get the number of queued calls, you will need to pass in the following parameters within a POST request:
Variable Name Location Description
apikey Header Your API Key, which you can generate from your dashboard
username Body Your Africa's Talking account username
phoneNumbers Body Your AfricasTalking phone number mapped to your account

You can check the HTTP Response Code to determine whether the request was successful. Any response code other than 201 (Created) indicates that the call was not initiated

Example using CURL client
curl -H "Accept: application/xml" -H "Apikey: fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" -d "username=myUsername&phoneNumbers=+254711082XXX" https://voice.africastalking.com/queueStatus