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;
}
?>