<?php
/**
* Classe para buscar última cotação de ações na Bovespa
*
* @package ws
* @access public
*
* @author Diego Giacomelli <hide@address.com>
* @version 1.0.0 31/08/2005
*
*/
class wsCStockFinder
{
/**
* @var
*/
var $quotation;
/**
* @var
*/
var $oscillation;
/**
* Construtor da classe
*
* @access public
* @return void
*
* @author Diego Giacomelli <hide@address.com>
* @since 1.0.0 31/08/2005
* @version 1.0.0 31/08/2005
*
*/
function wsCStockFinder()
{
$this->quotation = "";
$this->oscillation = "";
$this->isError = false;
}
/**
* Construtor da classe
*
* @param string $stockCode O código da ação
*
* Retorna true se conseguir coletar as informações sobre a ação com
* sucesso, caso contrário retorna false
*
*
* @access public
* @return bool
*
* @author Diego Giacomelli <hide@address.com>
* @since 1.0.0 31/08/2005
* @version 1.0.0 31/08/2005
*
*/
function getStockInformation($stockCode)
{
$stockInformation = file_get_contents("http://www.bovespa.com.br/Cotacoes2000/CotacaoRapidaHome.Asp?txtCodigo=" . $_POST["stock"]);
preg_match_all("/<p align=\"right\">(\S+)<\/font>/i", $stockInformation, $matches);
if(count($matches) < 2 || count($matches[1]) < 2)
return false;
$this->quotation = $matches[1][1];
$this->oscillation = $matches[1][0];
return true;
}
/**
* Obtém a cotação da ação coletada em getStockInformation
*
* @access public
* @return string
*
* @author Diego Giacomelli <hide@address.com>
* @since 1.0.0 31/08/2005
* @version 1.0.0 31/08/2005
*
*/
function getQuotation()
{
return $this->quotation;
}
/**
* Obtém a oscilação da ação coletada em getStockInformation
*
* @access public
* @return string
*
* @author Diego Giacomelli <hide@address.com>
* @since 1.0.0 31/08/2005
* @version 1.0.0 31/08/2005
*
*/
function getOscillation()
{
return $this->oscillation;
}
}
?>