nurjns icon

PHP: Prüfen, ob Twitch Streamer live ist

nurjns | PRO | 04/19/20 01:31:30 PM UTC | 0 ⭐ | 468 👁️ | Never ⏰ | []
PHP |

390 B

|

None

|

0 👍

/

0 👎

<?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