<?php
$apiUrl = "https://api.insel-monarchie.de/news";
$apiKey = "29db41d318450f836451d54358da9ba3";
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"API_KEY: $apiKey"
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$response_array = json_decode($response, true);
$news = $response_array['news'];
// News anzeigen...
} else {
echo "Fehler: HTTP $httpCode";
}
} catch (Exception $e) {
echo "Ein Fehler ist aufgetreten: " . $e->getMessage();
}
?>