diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..b20a429 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,49 @@ +{ + "version": "2.0.0", + "options": { + "env": { + "APP_PROTOCOL": "http", + "APP_HOST": "localhost", + "APP_PORT": "3002" + } + }, + "tasks": [ + { + "label": "launch-browser", + "type": "shell", + "windows": { + "command": "${command:workbench.action.terminal.sendSequence}", + "args": [ + { + "text": "start ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}\n" // For Windows + } + ], + "problemMatcher": [] + }, + "linux": { + "command": "/bin/bash", + "args": [ + "-c", + "if grep -q microsoft /proc/version; then powershell.exe Start-Process ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}; else xdg-open ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}; fi" + ], + "problemMatcher": [] + }, + "osx": { + "command": "open ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}", // For macOS + "problemMatcher": [] + } + }, + { + "label": "php-server", + "type": "shell", + "command": "php -S ${APP_HOST}:${APP_PORT}", + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": [ + "launch-browser" + ] + } + ] +} diff --git a/composer.lock b/composer.lock index 260449f..d73804b 100644 --- a/composer.lock +++ b/composer.lock @@ -9,12 +9,12 @@ "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": ">=7.4" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/index.php b/index.php index 3496a65..1a8766d 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,6 @@ 'Blessed ', '/Antiochia/' => 'Antiochia', @@ -359,8 +358,7 @@ private function sendMetadataReq(): void */ /** * Sends a request to the calendar API at $this->CalendarURL - * with the query parameters $this->queryParams, with the - * Accept-Language header set to $this->Locale and the + * with the Accept-Language header set to $this->Locale and the * Accept header set to application/json. * * If the request fails, it will die with an error message. @@ -374,7 +372,7 @@ private function sendReq() curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $this->CalendarURL); curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->queryParams)); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(["year_type" => "CIVIL"])); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Accept-Language: $this->Locale", "Accept: application/json" @@ -413,7 +411,8 @@ private function filterEventsToday() { $dateTimeToday = ( new \DateTime('now') )->format("Y-m-d") . " 00:00:00"; $dateToday = \DateTime::createFromFormat('Y-m-d H:i:s', $dateTimeToday, new \DateTimeZone('UTC')); - $dateTodayTimestamp = intval($dateToday->format("U")); + $dateTodayTimestampStr = $dateToday->format("U"); + $dateTodayTimestamp = intval($dateTodayTimestampStr); $dateToday->add(new \DateInterval('PT15M')); $idx = 0; foreach ($this->LitCalData as $value) { @@ -660,6 +659,8 @@ private function sendResponse() echo json_encode($this->LitCalFeed[0]); } elseif (count($this->LitCalFeed) > 1) { echo json_encode($this->LitCalFeed); + } else { + die("Missing data from response: LitCalFeed seems to by empty or null? " . count($this->LitCalFeed)); } }