From ecb7145f6ed3a641299279db5b4cfc227e6feef1 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 15 Jan 2023 10:30:35 -0700 Subject: [PATCH] fix: Convert images to associative array (#89) --- api/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/index.php b/api/index.php index 6f19d72..bdcf7b8 100644 --- a/api/index.php +++ b/api/index.php @@ -80,12 +80,12 @@ if (preg_match("/\/images\/(.*)$/", $_SERVER['REQUEST_URI'], $matches)) { } // fetch the list of images from GitHub -$images = json_decode(curlGetContents($GITHUB_API_URL, $REPO)); +$images = json_decode(curlGetContents($GITHUB_API_URL, $REPO), true); // if the random query string parameter is set, pick a random image if (isset($_GET['random'])) { // get the image url - $random_image_path = $images[array_rand($images)]->download_url; + $random_image_path = $images[array_rand($images)]["download_url"]; displayImage($random_image_path, $REPO, $redirect); } ?> @@ -225,7 +225,7 @@ if (isset($_GET['random'])) {