EurenikZ

PHP: Prüfen, ob Twitch Streamer live ist

Apr 19th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2. $headers = ['Client-ID: CLIENT_ID_HIER',];
  3. $handle = curl_init('https://api.twitch.tv/helix/streams?user_login=STREAMER_NAME_HIER');
  4. curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  5. curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
  6.  
  7. $response = curl_exec($handle);
  8. $json=json_decode($response)->data[0];
  9.  
  10. if(empty($json->type))
  11. {
  12.     echo 'Offline';
  13. }else{
  14.     echo 'Live!';
  15. }
  16. ?>
Add Comment
Please, Sign In to add comment