Advertisement
Crecket

Untitled

Jun 30th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 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 $result;
  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.  
  20. <?php if(getWebPage() == false): ?>
  21.     <img src="offline.jpg">
  22. <?php else: ?>
  23.     <img src="online.jpg">
  24. <?php endif;?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement