Heray-Was-Here
Server : Apache
System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /var/www/erp/htdocs/custom/crindicadores/class/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/erp/htdocs/custom/crindicadores/class/crindicadoresAPI.class.php
<?php


class crindicadoresApi {

	public $APIKEY = false;
	public $ROOT = 'https://gee.bccr.fi.cr/Indicadores/Suscripciones/WS/wsindicadoreseconomicos.asmx/ObtenerIndicadoresEconomicos';

    var $timeDrift = 0;

    public function __construct($_apikey=false, $_root=false) {
		
        if ($_apikey) $this->APIKEY = $_apikey;
		if ($_root) $this->ROOT = $_root;

    }


    function call($method, $url, $body = NULL)
    {
        $url = $this->ROOT . $url;
        
		$bodystring = '{
				"Token":"'.$this->APIKEY.'"';

        if($body)
        {
			foreach($body as $key=>$value) { $bodystring .= ', '.$key.':'.$value; }	
        }

		$bodystring .= '}';
        
        	
		$headers = array('Content-Type: application/json');        	

        // Call
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	    //curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
		//curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        
        
        if($bodystring)
        {
			curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $bodystring);
        }
        $result = curl_exec($curl);
           
        if($result === FALSE)
        {
            echo curl_error($curl);
            return NULL;
        }
        return json_decode($result); 
    }

    function get($url)
    {
        return $this->call("GET", $url);
    }
    function put($url, $body)
    {
        return $this->call("PUT", $url, $body);
    }
    function post($url, $body)
    {
        return $this->call("POST", $url, $body);
    }
    function delete($url, $body = false)
    {
        return $this->call("DELETE", $url, $body);
    }
	
	function encode($string) {
		if (preg_match('!!u', $string))
		{
		   return $string;
		}
		else 
		{
		   return utf8_encode($string);
		}
	}
	
	function decode($string) {
		if (preg_match('!!u', $string))
		{
		   return utf8_decode($string);
		}
		else 
		{
		   return $string;
		}
	}
	
}

?>

Hry