Commence par installer notre bibliothèque avec Composer :
$ 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();
}
L'ensemble de la documentation client est accessible ici :
https://github.com/markus-perl/gender-api-client