<?php
// Be sure to include the file you've just downloaded
require_once('AfricasTalkingGateway.php');

// Specify your login credentials
$username   = "nessinfortech";
$apikey     = "dc013d9e2725ed67257387c35f61d209c775482b93aab364e9dddd18a1431a30";
// Create a new instance of our awesome gateway class
$gateway    = new AfricasTalkingGateway($username, $apikey);

// Any gateway errors will be captured by our custom Exception class below,
// so wrap the call in a try-catch block
try
{
  // Fetch the data from our USER resource and read the balance
  $data = $gateway->getUserData();
  $accBalance= $data->balance;
  $reply=array('status'=>"success",'balance'=>$accBalance);
                     echo json_encode($reply);

  // The result will have the format=> KES XXX
}
catch ( AfricasTalkingGatewayException $e )
{
  $reply=array('status'=>"failed",'balance'=>0);
                     echo json_encode($reply);
}
