Application Data

Fetching application data sample code

The PHP code snippet below shows how to send a fetch application data request.

The code uses our PHP SDK.

<?php
require 'vendor/autoload.php';
use AfricasTalking\SDK\AfricasTalking;

// Set your app credentials
$username    = "MyAppsUsername";
$apikey      = "MyAppAPIKey";

// Initialize the SDK
$AT          = new AfricasTalking($username, $apiKey);

// Get the application service
$application = $AT->application();

try {
    // Fetch the application data
    $data = $application->fetchApplicationData();

    print_r($data);
} catch(Exception $e) {
    echo "Error: ".$e->getMessage();
}

Initiate an application data request by making a HTTP GET request to the following endpoint:

Endpoints

Live: https://api.africastalking.com/version1/user
Sandbox: https://api.sandbox.africastalking.com/version1/user

The standard request headers are required when making this request.

Application Data Response

The body of the response will be a JSON object containing the following fields:

Parameter Description
UserData
Map
A Map which contains the application data.
  • UserData: Map
    • balance: String Your Africa's Talking application balance. The format of this string is: (3-digit Currency Code)(space)(Decimal Value) e.g KES 1785.50
{
    "userData": {
        "balance": "KES 1785.50"
    }
}