
03-27-2015, 12:44 PM
|
|
|
Join Date: May 2013
Location: Gettysburg, Pa
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили:
0 раз(а) в 0 сообщениях
|
|
Quote:
Originally Posted by Dave
This should work. Else, well... I guess I'm being an idiot.
PHP Code:
<?php $json_array = json_decode(@curl("https://api.twitch.tv/kraken/streams/" . $_GET['stream']), true); if($json_array['stream'] != NULL && isset($json_array['stream']['_id'])){ echo file_get_contents("online.png"); }else{ echo file_get_contents("offline.png"); }
function curl($url, $post = null, $retries = 3){ $curl = curl_init($url);
if(is_resource($curl) === true){ curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
if(isset($post) === true){ curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post, "", "&"): $post); }
$result = false;
while(($result === false) && (--$retries > 0)){ $result = curl_exec($curl); }
curl_close($curl); } return $result;
}
?>
|
again thank you...
I have this setup in a fixed slide-out tab via css that pulls out when hovering over it...what I was wondering is there any way to pull notifications off the above php script? I'm guessing some javascript is required in order to call the css class name to show the notification but clueless about javascript.
|