Installier zuerst unsere Library mit 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();
}
Link zur Client-Dokumentation auf Github:
https://github.com/markus-perl/gender-api-client