MadMakz
/
Misc-Tools
Archived
1
0
Fork 0

Updated layout on php/twitch/twitchstatus.php

This commit is contained in:
MadMakz 2014-02-15 15:18:51 +01:00
parent 58a9dcbc8b
commit 9297f163ae
1 changed files with 10 additions and 8 deletions

View File

@ -30,24 +30,26 @@ else{
$stream = "https://api.twitch.tv/kraken/streams/".$name;
$stream = json_decode(file_get_contents_curl($stream), true);
$stream = json_decode(_file_get_contents_curl($stream), true);
$account = "https://api.twitch.tv/kraken/channels/".$name;
$account = json_decode(file_get_contents_curl($account), true);
$account = json_decode(_file_get_contents_curl($account), true);
if(!$account["display_name"]){
exit("Unknown channel.");
}
$txt = "<b>".$account["display_name"]."</b><br><br>";
if($stream["stream"] != null){
$boxart = "http://static-cdn.jtvnw.net/ttv-boxart/".$stream["stream"]["game"].".jpg";
$txt .= "<small><b>Live!</b><br><br>";
$txt .= "<b>Playing:</b> ".$stream["stream"]["game"]."<br>";
$txt = "<b>".$stream["stream"]["channel"]["status"]."</b><br>";
$txt .= "<small><b>".$account["display_name"]."</b><br><br>";
$txt .= "<b>Live!</b><br><br>";
$txt .= "<b>Playing:</b> ".$stream["stream"]["game"]."<br><br>";
$txt .= "<b>Viewers:</b> ".$stream["stream"]["viewers"]."</small><br>";
$boxart = "http://static-cdn.jtvnw.net/ttv-boxart/".$stream["stream"]["game"].".jpg";
}
else{
$boxart = "http://img7.imageshack.us/img7/9652/offlineeu.jpg";
$txt = "<b>".$account["display_name"]."</b><br><br>";
$txt .= "<small><b>Offline.</b></small><br>";
$boxart = "http://img7.imageshack.us/img7/9652/offlineeu.jpg";
}
$txt .= "<br><a href=\"".$account["url"]."\" target=\"_blank\"><b>Go to Channel</b></a>";
@ -69,7 +71,7 @@ exit;
/* FUNCTIONS */
function file_get_contents_curl($url, $agent = "My Agent", $cookie = false, $post = false){
function _file_get_contents_curl($url, $agent = "My Agent", $cookie = false, $post = false){
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);