diff --git a/Minecraft-Modern-Theme/test-api-key.php b/Minecraft-Modern-Theme/test-api-key.php new file mode 100644 index 0000000..a320528 --- /dev/null +++ b/Minecraft-Modern-Theme/test-api-key.php @@ -0,0 +1,98 @@ + 10)); + +if (is_wp_error($response)) { + echo "❌ Fehler beim API Request: " . $response->get_error_message() . "\n"; + exit; +} + +$status_code = wp_remote_retrieve_response_code($response); +echo "HTTP Status: $status_code\n\n"; + +if ($status_code !== 200) { + echo "❌ API Fehler (Status $status_code)\n"; + $body = wp_remote_retrieve_body($response); + $data = json_decode($body, true); + + if (isset($data['error']['message'])) { + echo "Fehlermeldung: " . $data['error']['message'] . "\n"; + + if (strpos($data['error']['message'], 'API key not valid') !== false) { + echo "\n⚠️ Der API Key ist ungültig!\n"; + echo "Bitte überprüfe den Key im Customizer oder erstelle einen neuen.\n"; + } + } + exit; +} + +$body = wp_remote_retrieve_body($response); +$data = json_decode($body, true); + +if (empty($data['items'])) { + echo "❌ Video nicht gefunden oder nicht verfügbar\n"; + exit; +} + +echo "✅ API Key funktioniert!\n\n"; + +$video = $data['items'][0]; +$title = $video['snippet']['title'] ?? 'Unbekannt'; +$state = $video['snippet']['liveBroadcastContent'] ?? 'none'; + +echo "Video Titel: $title\n"; +echo "Live Status: $state\n"; + +if ($state === 'live') { + echo "🔴 Das Video ist LIVE!\n"; +} elseif ($state === 'upcoming') { + echo "⏰ Das Video ist geplant (noch nicht live)\n"; +} else { + echo "⚫ Das Video ist NICHT live (aufgezeichnet oder offline)\n"; +} + +echo "\n=== Test erfolgreich ===\n";