I'm trying to use a project available in github to query for a license plate, it returns if the vehicle has or is not sinister from theft, it happens that when I try to test the following message appears
"Array ( [codigoRetorno] => 1 [mensagemRetorno] => Erro no processamento da consulta. ) O ano do veiculo eh"
I saw a stolen motorcycle being stored in a garage, "I know it was stolen by the situation ...", I wrote down the card with a lot of difficulty because it was doubled, but when I went consult the board, do not hit the bike in question. So I thought, and if I can create a loop that looks for a vehicle with the characteristics and some characters of the board, I could filter and actually find the correct board.
Library
Install the latest version with:
composer require chapeupreto/sinesp
Usage
Below is a simple and general example of using the library:
<?php
require 'vendor/autoload.php';
use Sinesp\Sinesp;
$veiculo = new Sinesp;
try {
$veiculo->buscar('GWW-6471');
if ($veiculo->existe()) {
print_r($veiculo->dados());
echo 'O ano do veiculo eh ' , $veiculo->anoModelo, PHP_EOL;
}
} catch (\Exception $e) {
echo $e->getMessage();
}
The buscar()
method must be the first method to invoke. This method is used to locate vehicle information with the board informed.
After calling the buscar()
method, the dados()
method will return an associative array containing all vehicle information.
Also, instead of using the entire array returned by the data () method, one can also retrieve an information in isolation by accessing it as an attribute of the object:
echo 'O municipio do veiculo é ', $veiculo->municipio;
Proxy
SINESP can block connections from outside the country. If the query does not return results due to connection error (for example, timeout error), a query can be performed using proxy.
There are several free proxy (e.g., link ) that can be easily found on the Internet. An example proxy use is below:
$veiculo = new Sinesp;
$veiculo->proxy('177.54.144.208', '80'); // Com proxy, esse metodo deve ser
call before method buscar()
$veiculo->buscar('GWW-6471');
print_r($veiculo->dados());
Optionally, instead of using the proxy($ip, $porta)
method, you can use an associative array with the ip and port keys as the second argument of the buscar()
method:
$veiculo = new Sinesp;
$veiculo->buscar('GWW-6471', ['ip' => '177.54.144.208', 'porta' => '80']); // a consulta usara o proxy especificado
print_r($veiculo->dados());
follows the repository.