Witam.
Metodą prób i błędów stworzyłem kod, który miał za zadanie pokazywać streamerów z platformy Twitch, którzy aktualnie grają w określoną grę.
Niestety - kod działał parę dni, lecz później bez żadnego konkretnego powodu przestał działać.
Jest dosyć chaotyczny, posiada dużo powtórzeń itp.
Poświęciłem mu dużo czasu i jak na samouka to uważam, że był progres, ale potrzebowałbym pomocy osób, które choć trochę znają się na tworzeniu czegoś podobnego.

Problemem jest niewykrywanie game_id. Zamiast pokazać stream, który jest aktywny (w tym przypadku grą jest Minecraft) pokazuje się komunikat "Brak streama z Minecrafta :(".
Umieszczam część kodu, która miała za zadanie wyświetlić aktywny stream z danej gry.

<?php
date_default_timezone_set('UTC');
$client_id = '';
 
$user1 = 'Skaju__';
$user2 = 'zalewa4';
$user3 = 'dprx';
$user4 = 'aczur';
$user5 = 'FlapuS_';
 
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, "https://api.twitch.tv/helix/streams?user_login=$user1");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array(
    "Client-ID: $client_id"
));
$profile_data1 = json_decode(curl_exec($ch1), true);
curl_close($ch1);
 
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, "https://api.twitch.tv/helix/streams?user_login=$user2");
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch2, CURLOPT_HTTPHEADER, array(
    "Client-ID: $client_id"
));
$profile_data2 = json_decode(curl_exec($ch2), true);
curl_close($ch2);
 
$ch3 = curl_init();
curl_setopt($ch3, CURLOPT_URL, "https://api.twitch.tv/helix/streams?user_login=$user3");
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch3, CURLOPT_HTTPHEADER, array(
    "Client-ID: $client_id"
));
$profile_data3 = json_decode(curl_exec($ch3), true);
curl_close($ch3);
 
$ch4 = curl_init();
curl_setopt($ch4, CURLOPT_URL, "https://api.twitch.tv/helix/streams?user_login=$user4");
curl_setopt($ch4, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch4, CURLOPT_HTTPHEADER, array(
    "Client-ID: $client_id"
));
$profile_data4 = json_decode(curl_exec($ch4), true);
curl_close($ch4);
 
$ch5 = curl_init();
curl_setopt($ch5, CURLOPT_URL, "https://api.twitch.tv/helix/streams?user_login=$user5");
curl_setopt($ch5, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch5, CURLOPT_HTTPHEADER, array(
    "Client-ID: $client_id"
));
$profile_data5 = json_decode(curl_exec($ch5), true);
curl_close($ch5);
 
if (!isset($profile_data1['data'][0])) {
    $live1 = 0;
} else {
    $live1 = 1;
}
if ($live1 == 1) {
    $game_id1 = $profile_data1['data'][0]['game_id'];
}
if ($game_id1 == 27471) {
    $streamtest1 = 'Skaju__';
}
if ($live1 == 0) {
    $offline1 = 'Brak streama z Minecrafta :(';
}
if ($game_id1 != 27471) {
    $offline1 = 'Brak streama z Minecrafta :(';
}
 
 
if (!isset($profile_data2['data'][0])) {
    $live2 = 0;
} else {
    $live2 = 1;
}
if ($live2 == 1) {
    $game_id2 = $profile_data2['data'][0]['game_id'];
}
if ($game_id2 == 27471) {
    $streamtest2 = 'Zalewa4';
}
if ($live2 == 0) {
    $offline2 = 'Brak streama z Minecrafta :(';
}
if ($game_id2 != 27471) {
    $offline2 = 'Brak streama z Minecrafta :(';
}
 
 
if (!isset($profile_data3['data'][0])) {
    $live3 = 0;
} else {
    $live3 = 1;
}
if ($live3 == 1) {
    $game_id3 = $profile_data3['data'][0]['game_id'];
}
if ($game_id3 == 27471) {
    $streamtest3 = 'DPRX';
}
if ($live3 == 0) {
    $offline3 = 'Brak streama z Minecrafta :(';
}
if ($game_id3 != 27471) {
    $offline3 = 'Brak streama z Minecrafta :(';
}
 
 
if (!isset($profile_data4['data'][0])) {
    $live4 = 0;
} else {
    $live4 = 1;
}
if ($live4 == 1) {
    $game_id4 = $profile_data4['data'][0]['game_id'];
}
if ($game_id4 == 27471) {
    $streamtest4 = 'Aczur';
}
if ($live4 == 0) {
    $offline4 = 'Brak streama z Minecrafta :(';
}
if ($game_id4 != 27471) {
    $offline4 = 'Brak streama z Minecrafta :(';
}
 
 
if (!isset($profile_data5['data'][0])) {
    $live5 = 0;
} else {
    $live5 = 1;
}
if ($live5 == 1) {
    $game_id5 = $profile_data5['data'][0]['game_id'];
}
if ($game_id5 == 27471) {
    $streamtest5 = 'FlapuS_';
}
if ($live5 == 0) {
    $offline5 = 'Brak streama z Minecrafta :(';
}
if ($game_id5 != 27471) {
    $offline5 = 'Brak streama z Minecrafta :(';
}
 
<---html--->
 
        <header class="masthead bg-primary text-white">
                <div class="content">
                    <img class="masthead-avatar mb-5" src="assets/img/ttv.png" alt=""><br>
                    <button class="tablink" onclick="openPage('Skaju__', this, '#9e2833')" id="defaultOpen">Skaju__</button>
                    <button class="tablink" onclick="openPage('Zalewa4', this, '#9e2833')" >Zalewa4</button>
                    <button class="tablink" onclick="openPage('DPRX', this, '#9e2833')" >DPRX</button>
                    <button class="tablink" onclick="openPage('Aczur', this, '#9e2833')" >Aczur</button>
                    <button class="tablink" onclick="openPage('FlapuS_', this, '#9e2833')" >FlapuS_</button>
                    <p><div id="Skaju__" class="tabcontent">
                    <p><h1 class="mb-0"><?php echo $streamtest1 ?><?php echo $offline1 ?></h1></p>
                    <div id="twitch-embed1"></div>
                    <script src="https://embed.twitch.tv/embed/v1.js"></script>
                    </div>
                    <div id="Zalewa4" class="tabcontent">
                    <p><h1 class="mb-0"><?php echo $streamtest2 ?><?php echo $offline2 ?></h1></p>
                    <div id="twitch-embed2"></div>
                    <script src="https://embed.twitch.tv/embed/v1.js"></script>
                    </div>
                    <div id="DPRX" class="tabcontent">
                    <p><h1 class="mb-0"><?php echo $streamtest3 ?><?php echo $offline3 ?></h1></p>
                    <div id="twitch-embed3"></div>
                    <script src="https://embed.twitch.tv/embed/v1.js"></script>
                    </div>
                    <div id="Aczur" class="tabcontent">
                    <p><h1 class="mb-0"><?php echo $streamtest4 ?><?php echo $offline4 ?></h1></p>
                    <div id="twitch-embed4"></div>
                    <script src="https://embed.twitch.tv/embed/v1.js"></script>
                    </div>
                    <div id="FlapuS_" class="tabcontent">
                    <p><h1 class="mb-0"><?php echo $streamtest5 ?><?php echo $offline5 ?></h1></p>
                    <div id="twitch-embed5"></div>
                    <script src="https://embed.twitch.tv/embed/v1.js"></script>
                    </div></p>
                </div>
        </header>
 
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed1", {
        width: 854,
        height: 480,
        channel: "<?php echo $streamtest1 ?>",
        theme: "dark"
      });
    </script>
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed2", {
        width: 854,
        height: 480,
        channel: "<?php echo $streamtest2 ?>",
        theme: "dark"
      });
    </script>
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed3", {
        width: 854,
        height: 480,
        channel: "<?php echo $streamtest3 ?>",
        theme: "dark"
      });
    </script>
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed4", {
        width: 854,
        height: 480,
        channel: "<?php echo $streamtest4 ?>",
        theme: "dark"
      });
    </script>
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed5", {
        width: 854,
        height: 480,
        channel: "<?php echo $streamtest5 ?>",
        theme: "dark"
      });
    </script>
 
<script>
function openPage(pageName, elmnt, color) {
  var i, tabcontent, tablinks, tablinkswh;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }
 
  tablinks = document.getElementsByClassName("tablink");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].style.backgroundColor = "";
  }
 
  document.getElementById(pageName).style.display = "block";
 
  elmnt.style.backgroundColor = color;
}
 
document.getElementById("defaultOpen").click();
</script>
<script>
function openPage(pageName, elmnt, color) {
  var i, tabcontent, tablinks, tablinkswh;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }

  tablinks = document.getElementsByClassName("tablink");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].style.backgroundColor = "";
  }

  document.getElementById(pageName).style.display = "block";

  elmnt.style.backgroundColor = color;
}

document.getElementById("defaultOpen").click();
</script>