Advertisement
Crecket

Untitled

Jun 30th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2. function getWebPage(){
  3.     $url = 'https://api.hitbox.tv/media/status/creativescapersps';
  4.     $ch = curl_init();
  5.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  7.     curl_setopt($ch, CURLOPT_URL,$url);
  8.     $result = curl_exec($ch);
  9.     curl_close($ch);
  10.     $result = json_decode($result, true);
  11.     if($result['media_is_live'] == 1){
  12.         return true;
  13.         //you could display the amount of viewers with $result['media_views'] if you want to
  14.     }else{
  15.         return false;
  16.     }
  17. }
  18.  
  19. if(getWebPage() == false){
  20.     $img = imagecreatefrompng('crsoffline.png');
  21. }else{
  22.     $img = imagecreatefrompng('crsonline.png');
  23. }
  24. header("Content-Type: image/png");
  25. imagepng($img);
  26. imagedestroy($img);
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement