Ok so I stored the token after your code
if ($info['http_code'] == 200) {
// Convert JSON data to object
$r = json_decode($data);
// Object contains an array of object call "data"
$array_data_r = $r->data;
} else {
echo 'Failed with ' . $info['http_code'];
}
$token= $r->access_token;
Then I basically took the code I already had by adjusting stuff:
$ch = curl_init('https://api.twitch.tv/helix/streams?user_login='.$streamer[$i]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: myclientID',
'Authorization: Bearer '. $token
));
So only thing remaining is to have this done on the server side and I’m good to go, right ? (as it is, it works, but I understand for security reason I can’t keep it on my webpage directly)