PHP code example of identify-africa / sdk

1. Go to this page and download the library: Download identify-africa/sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

identify-africa / sdk example snippets




dentifyAfrica\Client;
use IdentifyAfrica\Endpoints\NationalId;
use IdentifyAfrica\Models\NationalId\NationalIdRequest;

$client = new Client(
    apiKey: getenv('API_KEY'),
    apiSecret: getenv('API_SECRET')
);

$result = NationalId::verify($client, new NationalIdRequest(idnumber: '12345678'));

if ($result['success']) {
    echo $result['data']['first_name'] . PHP_EOL;
} else {
    echo $result['message'] . PHP_EOL;
}

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('identify-africa');
$logger->pushHandler(new StreamHandler('php://stdout'));

$client = new Client(
    apiKey: getenv('API_KEY'),
    apiSecret: getenv('API_SECRET'),
    logger: $logger
);

[
    'success' => bool,
    'response_code' => int,
    'message' => string,
    'data' => ..., // shape depends on endpoint and success/failure
    'request_id' => string,
]