'query', 'prop' => 'description|pageimages', 'titles' => $topic, 'pithumbsize' => 400, 'format' => 'json', ]); $lang = currentLang(); $url = "https://$lang.wikipedia.org/w/api.php?$query"; $response = null; try { $response = Http::get($url)->throw(); } catch (\Illuminate\Http\Client\RequestException) { // Ignore the exception. } if ($response === null || $response->json('query.pages.*.missing')[0] === true) { return [ 'url' => null, 'description' => null, 'thumbnail' => null, ]; } return [ 'url' => "https://$lang.wikipedia.org/wiki/".Str::slug($topic, language: $lang), 'description' => $response->json('query.pages.*.description')[0], 'thumbnail' => $response->json('query.pages.*.thumbnail.source')[0], ]; } }