phpDocumentor ApiUptimeRobot
[ class tree: ApiUptimeRobot ] [ index: ApiUptimeRobot ] [ all elements ]

Source for file ApiUptimeRobot.php

Documentation is available at ApiUptimeRobot.php

  1. <?php
  2.  
  3. /**
  4.  * API destinada a monitorar servidores utilizando o Uptime Robot
  5.  *
  6.  * @package ApiUptimeRobot
  7.  * @version 0.1
  8.  * @author Marcelo Bom Jardim Villasanin <marcelo@onzehost.com.br>
  9.  * @copyright Copyright (c) 2011, Marcelo Bom Jardim Villasanin
  10.  * @link http://www.onzehost.com.br
  11.  *
  12.  */
  13.  
  14. /**
  15.  * Api do Uptime Robot
  16.  * @package ApiUptimeRobot
  17.  */
  18. class ApiUptimeRobot {
  19.  
  20.   private $apiKey "";
  21.   private $urlApi "http://api.uptimerobot.com/";
  22.  
  23.   /**
  24.    * Configura a chave de acesso
  25.    *
  26.    * @param string $apiKey Configura a KEY disponivel no site uptimerobot.com
  27.    * @return null 
  28.    */
  29.   public function setApiKey($apiKey{
  30.     $this->apiKey $apiKey;
  31.   }
  32.  
  33.   /**
  34.    * Busca todos os servidores monitorados
  35.    *
  36.    * @return string 
  37.    */
  38.   public function getMonitors({
  39.     $oCurl curl_init();
  40.     curl_setopt($oCurlCURLOPT_URL,$this->urlApi."getMonitors?format=xml&apiKey=".$this->apiKey);
  41.     curl_setopt($oCurlCURLOPT_RETURNTRANSFERtrue);
  42.     $cResp curl_exec($oCurl);
  43.     $cErro curl_error($oCurl);
  44.  
  45.     if($cErro{
  46.       return false;
  47.     }
  48.  
  49.     curl_close($oCurl);
  50.  
  51.     return $cResp;
  52.   }
  53.  
  54.   /**
  55.    * Retorna a descrição do status
  56.    *
  57.    * @param $idStatus ID do status do servidor
  58.    * @return string Retorna o status de forma legivel
  59.    */
  60.   public static function getStatus($idStatus{
  61.  
  62.     $aStatus[1"Pausa";
  63.     $aStatus[2"Online";
  64.     $aStatus[8"Manutenção";
  65.     $aStatus[9"Offline";
  66.  
  67.     if(array_key_exists((int)$idStatus$aStatus)) {
  68.       return $aStatus[(int)$idStatus];
  69.     }
  70.   }
  71.  
  72. }
  73.  
  74. ?>

Documentation generated on Sat, 15 Oct 2011 12:48:48 -0300 by phpDocumentor 1.4.3