Your PHP is bad for want of better wording.
Try something more akin to
include("channels_list.php");
// play call API
foreach ($channels as $chans) {
$callAPI = implode('&user_login=', $chans);
$url="https://api.twitch.tv/helix/streams?user_login=" . $callAPI;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: c533u8ntdp29h42xxzwfe0pf5v66dm'
));
$result = curl_exec($ch);
$i = curl_getinfo($ch);
curl_close($ch);
$str = json_decode($result, true);
if ($i['http_code'] == 200) {
// play print API
// do stuff with $str has chnanels
} else {
// non 200 do somethign with the error
// do stuff with $str has error message
}
}
// end call API
$channels = array(
array(),
array(),
array(),
array(),
array()
);
$canale = "SELECT * FROM `ttp_tsp` ORDER BY id ASC LIMIT 0, 100";
$result = mysqli_query($connString, $canale)or die(mysqli_error());
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$channels[0][] = $row['canale'];
}
}
$canale = "SELECT * FROM `ttp_tsp` ORDER BY id ASC LIMIT 100, 100";
$result = mysqli_query($connString, $canale)or die(mysqli_error());
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$channels[1][] = $row['canale'];
}
}
$canale = "SELECT * FROM `ttp_tsp` ORDER BY id ASC LIMIT 200, 100";
$result = mysqli_query($connString, $canale)or die(mysqli_error());
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$channels[2][] = $row['canale'];
}
}
$canale = "SELECT * FROM `ttp_tsp` ORDER BY id ASC LIMIT 300, 100";
$result = mysqli_query($connString, $canale)or die(mysqli_error());
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$channels[3][] = $row['canale'];
}
}
$canale = "SELECT * FROM `ttp_tsp` ORDER BY id ASC LIMIT 400, 100";
$result = mysqli_query($connString, $canale)or die(mysqli_error());
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$channels[4][] = $row['canale'];
}
}
Also removed the accept header thats not needed with Helix.and added a curl 200 check.