hotrush/genderapi-client

0.1.2 2019-06-26 12:33 UTC

This package is auto-updated.

Last update: 2024-08-27 00:10:39 UTC


README

GenderApi.io API 的 PHP SDK

易于使用,API 密钥 可选。请在此处查看 API 文档 - https://genderapi.io/api-documentation

安装

composer require hotrush/genderapi-client 

使用

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();