Hallöchen,
ich möchte für mein Webradio die Sendungsinformation (Aktuelle Sendung, Moderator, Uhrzeit - also von bis, Beschreibung sowie aktuellen Titel sowie auch für die nachfolgende ohne halt die Beschreibung und Titel) umgestalten indem ich die in eine extra Seite mache und über ein Iframe z.B. integriere.
Hier nun meine Probleme:
1. Das Problem ist nun, dass wenn ich es "klassisch" wie hier beschrieben (Link: ONAIR - Beispiel) mache bekomme ich die Information nicht mehr (Array ist null). Nun habe ich es derzeit über cURL gemacht und es funktioniert derzeit aber ich frage mich halt warum es so nicht mehr funktioniert.
Hier der aktuelle Code wie ich es gelöst habe da ja bei mir leider es mit den klassischen Beispiel nicht funktioniert:
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="UTF-8">
- <title>Puppy Gaming Radio -ShowInfo-</title>
- <meta http-equiv="refresh" content="60">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" href="style.css">
- </head>
- <body>
- <?php
- // Abruf der Daten via Radio - Sendeplan
- // Abruf der Daten via Radio - Sendeplan
- $json_url = "(RADIO-URL) / sendeplan/index.php?page=infos&mode=json&opt=onair";
- $json_url2 = "(RADIO-URL)/ sendeplan /index.php?page=infos&mode=json&opt=next_onair";
- // JSon - Datei vorbereiten für späteren Abruf
- // cURL vorbereiten
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $json_url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
- // User-Agent setzen, damit der Server nicht blockiert
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; PuppyBot/1.0)');
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- $response = curl_exec($ch);
- curl_close($ch);
- $data = json_decode($response, true);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $json_url2);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
- // User-Agent setzen, damit der Server nicht blockiert
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; PuppyBot/1.0)');
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- $response = curl_exec($ch);
- curl_close($ch);
- $data2 = json_decode($response, true);
- ?>
- <!-- HTML für die Sendebox -->
- <div class="sendebox">
- <div class="sendeinfo">
- <h2><?php $curr_showname; ?></h2>
- <p><strong>Moderator:</strong> <?php echo $curr_mod; ?></p>
- <p><strong>Uhrzeit:</strong> <?php echo htmlspecialchars($data['von']) . ' - ' . htmlspecialchars($data['bis']); ?></p>
- <div class="beschreibung">
- <?php echo $data['beschreibung']; ?>
- </div>
- </div>
- <?php if (!empty($data['profil_bild'])): ?>
- <div class="moderatorbild">
- <img src="<?php echo htmlspecialchars($data['profil_bild']); ?>" alt="Moderator" />
- </div>
- <?php endif; ?>
- <?php echo "Aktueller Song: ".$data2['currentsong'];?>
- </div>
- <? echo "Aktuelle Sendung: $curr_showname"; ?>
- <!-- <? echo "pre>";
- print_r($data);
- echo "</pre>";
- ?> -->
- </body>
- </html>
2. Ich bekomme irgendwie es nicht mehr hin die Angaben über $data / $data2 (JSON für ONAIR / NEXT-ONAIR) richtig abzugreifen, kann mir da jemand die Begriffe nochmal genau nennen ?
Vielen Dank für eure Hilfe
Grüße von euren
Puppy Bosko