Exemple #1
0
 function above_fipe($version_id, $price)
 {
     $this->get($version_id);
     if (!empty((array) $this->object)) {
         $price = reaisToFloat($price);
         return $price > $this->object->price;
     }
     return false;
 }
Exemple #2
0
 function api_get_price()
 {
     $this->load->model("../libraries/anuncios/model/ad_version_model", 'version_model');
     $brand = $this->input->post('brand', TRUE);
     $model = $this->input->post('model', TRUE);
     $year = $this->input->post('year', TRUE);
     $version = $this->input->post('version', TRUE);
     $url = "http://www.webmotors.com.br/avaliacao/tabelawebmotors?TipoVeiculo=1&tipo=meuveiculo&estado=RS&marca={$brand}&modelo={$model}&ano={$year}&versao={$version}";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_FAILONERROR, 0);
     $data = curl_exec($ch);
     curl_close($ch);
     // dump($data);
     $start = strpos($data, "wm.tab_fipe") + 22;
     $end = strpos($data, "wm.tab_min") - 18;
     $valor = substr($data, $start, $end - $start);
     $valor = reaisToFloat($valor);
     $this->version_model->get($version);
     $this->version_model->object->price = $valor;
     $this->version_model->update();
 }
Exemple #3
0
 function post_to_values($ad)
 {
     $this->object = $ad;
     //validacao vai aquyi
     $this->object["price"] = reaisToFloat($this->object["price"]);
     $this->object = (object) $this->object;
     return $this->object;
 }