PHP code example of faicchia / laravel-nationalize
1. Go to this page and download the library: Download faicchia/laravel-nationalize library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
faicchia / laravel-nationalize example snippets
$response = Nationalize::name('Michael')->get()
print $response->status // 200 - HTTP response code
print $response->limit // 1000 - The amount of names available in the current time window
print $response->remaining // 728 - The number of names left in the current time window
print $response->reset // 15281 - Seconds remaining until a new time window opens
print $response->error // null - Error string
print $response->result->name // Michael
print $response->result->countries
// [
// "US" => 0.08986482266532715,
// "AU" => 0.05976757527083082,
// "NZ" => 0.04666974820852911
// ]
$response = Nationalize::name(['Michael', 'Kevin'])->get()
// or
$response = Nationalize::names(['Michael', 'Kevin'])->get()
foreach ($response->result as $prediction) {
print $prediction->name
print $prediction->countries
}
// e.g. Invalid API Key
$response = Nationalize::name('Michael')->get()
print $response->status // 401
print $response->error // "Invalid API key"