Guest User

Untitled

a guest
Aug 25th, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $stream = $_GET['stream'];
  5.  
  6. $json_file = @curl("http://api.justin.tv/api/stream/list.json?channel=croninlol");
  7. $json_array = json_decode($json_file, true);
  8.  
  9. if (strtolower($json_array[0]['name']) == strtolower("live_user_croninlol")) {
  10. echo file_get_contents("online.png");
  11. }else{
  12. echo file_get_contents("offline.png");
  13. }
  14.  
  15. function curl($url, $post = null, $retries = 3){
  16. $curl = curl_init($url);
  17.  
  18. if(is_resource($curl) === true){
  19. curl_setopt($curl, CURLOPT_FAILONERROR, true);
  20. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  21. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  22. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  23. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  24.  
  25. if(isset($post) === true){
  26. curl_setopt($curl, CURLOPT_POST, true);
  27. curl_setopt($curl, CURLOPT_POSTFIELDS, (is_array($post) === true) ? http_build_query($post, "", "&"): $post);
  28. }
  29.  
  30. $result = false;
  31.  
  32. while(($result === false) && (--$retries > 0)){
  33. $result = curl_exec($curl);
  34. }
  35.  
  36. curl_close($curl);
  37. }
  38. return $result;
  39.  
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment