Primero instala nuestra biblioteca con el compositor:
$ composer require gender-api/client
use GenderApi\Client as GenderApiClient;
try {
$apiClient = new GenderApiClient('insert your API key');
$lookup = $apiClient->getByFirstName('elisabeth');
if ($lookup->genderFound()) {
echo $lookup->getGender();
}
$lookup = $apiClient->getByFirstNameAndLastNameAndCountry('Thomas Johnson', 'US');
if ($lookup->genderFound()) {
echo $lookup->getGender();
echo $lookup->getFirstName();
echo $lookup->getLastName();
}
} catch (GenderApi\Exception $e) {
echo 'Exception: ' . $e->getMessage();
}
Vea la documentación completa del cliente aquí:
https://github.com/markus-perl/gender-api-client