PHP code example of hotrush / genderapi-client

1. Go to this page and download the library: Download hotrush/genderapi-client 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/ */

    

hotrush / genderapi-client example snippets


use Hotrush\GenderApi\GenderApiClient;
use Hotrush\GenderApi\Adapter\GuzzleHttpAdapter;

$client = new GenderApiClient(
    new GuzzleHttpAdapter($apiToken)
);

$nameData = $client->getGender($name, $countryCode);
echo $nameData->getGender();

$namesData = $client->getGendersBatch($namesArray, $countryCode);
foreach ($namesData as $nameData) {
    echo $nameData->getGender().PHP_EOL;
    echo $nameData->getName().PHP_EOL;
    echo $nameData->getProbability().PHP_EOL;
}

$nameData = $client->getGenderByEmail($name, $countryCode);
echo $nameData->getGender();