Now i changed my code, but not work, i’m going crazy ç_ç
$cho = curl_init('https://id.twitch.tv/oauth2/token');
curl_setopt($cho, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($cho, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cho, CURLOPT_POST, 1);
$fields = array(
'client_id' => 'c533u8ntdp29h42xxzwfe0pf5v66dm',
'client_secret' => 'xxxxxxxxxxx',
'grant_type' => 'client_credentials',
'token_type' => 'bearer',
'state' => $_GET['state']
);
curl_setopt($cho, CURLOPT_POSTFIELDS, $fields);
$output = curl_exec($cho);
$info = curl_getinfo($cho);
print_r($info);
$oauth = json_decode($output, true);
$token = $oauth['access_token'];
print_r($token);
// start call API
$all_channels = [];
foreach($channels as $chans){
if (count($chans) > 0) {
$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',
'Authorization: Bearer '.$token
));
$result = curl_exec($ch);
$i = curl_getinfo($ch);
curl_close($ch);
// stampo API
$str = json_decode($result, true);
OPS sorry