프로그래밍 언어별로 사용할 수 있는 라이브러리를 제공하나요?
우리 API는 구조가 아주 단순해서, jQuery 플러그인을 제외하고는 별도의 언어별 라이브러리를 제공하지 않아.
대부분의 프로그래밍 언어는 기본적으로 JSON 파서를 지원하고, 그렇지 않은 언어들도 이미 외부 라이브러리가 많이 있어.
API를 바로 써보고 싶다면, 아래의 코딩 예제를 참고해 시작해 봐
먼저 composer로 우리 라이브러리를 설치해 줘:
$ composer require gender-api/client
use GenderApi\Client as GenderApiClient;
try {
$apiClient = new GenderApiClient('insert your API key');
// Query a single name
$lookup = $apiClient->getByFirstName('elisabeth');
if ($lookup->genderFound()) {
echo $lookup->getGender(); // female
}
// Query a full name and improve the result by providing a country code
$lookup = $apiClient->getByFirstNameAndLastNameAndCountry('Thomas Johnson', 'US');
if ($lookup->genderFound()) {
echo $lookup->getGender(); // male
echo $lookup->getFirstName(); // Thomas
echo $lookup->getLastName(); // Johnson
}
} catch (GenderApi\Exception $e) {
// Name lookup failed due to a network error or insufficient remaining requests
// left. See https://gender-api.com/en/api-docs/error-codes
echo 'Exception: ' . $e->getMessage();
}
전체 클라이언트 문서는 여기에서 확인해 줘:
연관 키워드
이 글이 도움이 되었어?