Skip to content

xnekv03/nameday-api

Repository files navigation

Official International Name days API library

Name day API library for nameday.abalin.net

This library makes it easy to send requests towards nameday.abalin.net API. API provides name days for various countries.

Installation

The recommended way to install package is through Composer.

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of package:

composer require xnekv03/nameday-api

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

You can then later update package using composer:

composer update

List of supported countries

  • Country names
    • United States
    • Czech Republic
    • Slovakia
    • Poland
    • France
    • Hungary
    • Croatia
    • Sweden
    • Austria
    • Italy
    • Germany
    • Spain
  • Country codes
    • us
    • cz
    • sk
    • pl
    • fr
    • hu
    • hr
    • se
    • at
    • it
    • de
    • es

Usage

create an instance of the class
use Xnekv03\ApiNameday\ApiNamedayClass as Nameday;

$nameday = new Nameday();
$nameday = new Nameday('America/Vancouver'); # time zone specification, other then system default (see below)
Request name days for today / tomorrow / yesterday
echo $nameday->today(); # {"data":{"day":27,"month":8,"name_us":"Caesar, Cesar ... }}
echo $nameday->tomorrow(); # {"data":{"day":28,"month":8,"name_us":"Agustin, August, Augusta ... }}
echo $nameday->yesterday(); # {"data":{"day":26,"month":8,"name_us":"Percival, Percy ... }}
Request name days for specific date
echo $nameday->specificDay(int $day, int $month);
echo $nameday->specificDay(21,10); # {"data":{"day":21,"month":10,"name_us":"Celina, Celine, Nobel" ... }}
Request name day in country calendar

Will return all days which contains the name.

searchByName(string $name)

echo $nameday->searchByName('Jan'); # {"calendar":"cz","results":[{"day":24,"month":5,"name":"Jana"},{"day":24,"month":6,"name":"Jan"} ... }}

Specification of time zone

Time zone is set by local php.ini settings. Therefore $nameday->today() will return result according to that. If you need to specify different time zone you can do so by adding optional parameter $timeZone to the constructor. $timeZone must be PHP time zones string or integer offset to GMT.

$nameday = new Nameday('Pacific/Honolulu');
echo $nameday->today(); # will return today name days according to Pacific/Honolulu time zone
$nameday = new Nameday('+13:30');
echo $nameday->tomorrow(); # will return today name days according to given UTC offset

Certificate

Make sure you have proper certificates stored on your local machine as Name day API uses HTTPS only.

If you run into problems with server certificate try downloading the The Mozilla CA certificate store, save it on your system and configure php.ini

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\...\cacert.pem"