. * * * Usage: echo _hitbox_status(""); * */ error_reporting(0); function _hitbox_status($channel = false){ if(isset($channel)){ $name = $channel; } else{ $name = "hitboxlive"; } $stream = "http://api.hitbox.tv/media/live/".$name; $stream = json_decode(_file_get_contents_curl($stream), true); $account = "http://api.hitbox.tv/user/".$name; $account = json_decode(_file_get_contents_curl($account), true); if(!$account["user_name"]){ $return = "Unknown channel."; return $return; } if($stream["livestream"][0]["media_is_live"] != 0){ $txt = "".$stream["livestream"][0]["media_status"]."
"; $txt .= "".$account["user_name"]."

"; $txt .= "Live!

"; if(!empty($stream["livestream"][0]["category_name"])){ $txt .= "Playing: ".$stream["livestream"][0]["category_name"]."

"; $boxart = "http://edge.sf.hitbox.tv".$stream["livestream"][0]["category_logo_large"]; }else{ $boxart = "http://i.imgur.com/bwqCxgg.jpg"; } $txt .= "Viewers: ".$stream["livestream"][0]["media_views"]."

"; } else{ $txt = "".$account["user_name"]."

"; $txt .= "Offline.
"; $boxart = "http://i.imgur.com/TqKeUSn.jpg"; } $txt .= "
Go to Channel"; $return = "
".$txt." \"\"
"; return $return; } /* FUNCTIONS */ function _file_get_contents_curl($url, $agent = "My Agent", $cookie = false, $post = false){ $ch = curl_init(); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $agent); if($cookie){ curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_COOKIE, $cookie); } curl_setopt($ch, CURLOPT_URL, $url); if($post){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } $data = curl_exec($ch); curl_close($ch); return $data; } ?>