PHP: Prüfen, ob Twitch Streamer live ist
<?php
$headers = ['Client-ID: CLIENT_ID_HIER',];
$handle = curl_init('https://api.twitch.tv/helix/streams?user_login=STREAMER_NAME_HIER');
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($handle);
$json=json_decode($response)->data[0];
if(empty($json->type))
{
echo 'Offline';
}else{
echo 'Live!';
}
?>
Comments