First install our library with 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();
}
See full client documentation here:
https://github.com/markus-perl/gender-api-client