![]() |
Days of the week |
Register and receive a token to access the API. The token will be available in your personal account.
Demo token 68a8a656-1811-409a-9418-dae2631e2320 (The token is valid on average for about three days).
The code outputs the names of the days of the week
in different languages.
In the line echo $data['English']['day']; change English to the desired language provided above in the comments.
Don't forget to change the demo token to yours.
In the line echo $data['English']['day']; change English to the desired language provided above in the comments.
Don't forget to change the demo token to yours.
<?php
// We get the current day of the week number
$dayOfWeek = date('N');
// $dayOfWeek = 0; // Sunday
// $dayOfWeek = 1; // Monday
// $dayOfWeek = 2; // Tuesday
// $dayOfWeek = 3; // Wednesday
// $dayOfWeek = 4; // Thursday
// $dayOfWeek = 5; // Friday
// $dayOfWeek = 6; // Saturday
// Demo token. (Replace it with your token).
$token = '68a8a656-1811-409a-9418-dae2631e2320';
// Form the URL using the token and day of the week
$url = 'https://wildtracks.pro/api/days_of_the_week/' . $token . '/' . $dayOfWeek;
// Initializing cURL
$ch = curl_init();
// cURL Settings
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Executing the request
$response = curl_exec($ch);
// Checking for errors
if (curl_errno($ch)) {
die('cURL error: ' . curl_error($ch));
}
// Closing the cURL session
curl_close($ch);
// Decoding the JSON response
$data = json_decode($response, true);
// Checking for decoding errors
if (json_last_error() !== JSON_ERROR_NONE) {
die('Error decoding JSON: ' . json_last_error_msg());
}
// Chinese
// Spanish
// English
// Hindi
// Arab
// Bengal
// Portuguese
// Russian
// Japanese
// Lahnda
// Marathi
// Telugu
// Malay
// Turkish
// Korean
// French
// German
// Vietnamese
// Tamil
// Urdu
// Javanese
// Italian
// Persian
// Gujaratis
// Outputting the day of the week in English
echo $data['English']['day'];
// echo $data['English']['lang']; //Language
// echo $data['English']['country']; //Country
// echo $data['English']['code']; //Country code
// echo $data['English']['transcription']; //Transcription of the name of the day of the week
?>
Description of fields:
lang | Language |
country | Country |
code | Country code |
day | Name of the day of the week |
transcription | Transcription of the name of the day of the week |