File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,23 @@ Cada classe possui os seguintes métodos:
32
32
Veja um exemplo de como consultar as marcas de carros:
33
33
~~~ php
34
34
<?php
35
+ use DeividFortuna\Fipe\FipeCarros;
36
+
37
+ $marcas = FipeCarros::getMarcas();
35
38
39
+ var_dump($marcas);
40
+ ~~~
41
+
42
+ Utilizando o token de acesso para aumentar o limite de requisições:
43
+ ~~~ php
44
+ <?php
36
45
use DeividFortuna\Fipe\FipeCarros;
37
46
47
+ $token = 'SEU_TOKEN';
48
+ IFipe::setCurlOptions([
49
+ CURLOPT_HTTPHEADER => ["X-Subscription-Token:$token"]
50
+ ]);
51
+
38
52
$marcas = FipeCarros::getMarcas();
39
53
40
54
var_dump($marcas);
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " deividfortuna/fipe" ,
3
3
"description" : " Tabela Fipe Lib" ,
4
- "version" : " 2.4.1 " ,
4
+ "version" : " 2.5.0 " ,
5
5
"license" : " MIT" ,
6
6
"authors" : [
7
7
{
Original file line number Diff line number Diff line change 9
9
$ codModelo = filter_input (INPUT_GET , 'codModelo ' );
10
10
$ codAno = filter_input (INPUT_GET , 'codAno ' );
11
11
12
+ // Caso você tenha um token de assinatura, pode passá-lo como um cabeçalho HTTP
13
+ // $token = 'SEU_TOKEN_AQUI';
14
+
12
15
IFipe::setCurlOptions ([
13
- CURLOPT_TIMEOUT => 10 ,
16
+ CURLOPT_TIMEOUT => 10 ,
14
17
CURLOPT_CONNECTTIMEOUT => 10 ,
18
+ // CURLOPT_HTTPHEADER => ["X-Subscription-Token:$token"]
15
19
]);
16
20
17
21
$ marcas = FipeCarros::getMarcas ();
22
+
18
23
if ($ codMarca ) {
19
24
$ modelos = FipeCarros::getModelos ($ codMarca );
20
25
$ modelos = $ modelos ['modelos ' ];
38
43
}
39
44
} catch (Exception $ e ) {
40
45
header ('Content-Type: text/html; charset=utf-8 ' );
41
- die ('ERRO: ' . $ e ->getMessage ());
46
+ die ('ERRO: ' . $ e ->getMessage ());
42
47
}
43
48
?>
44
49
<!DOCTYPE html>
59
64
</style>
60
65
<body>
61
66
<p>Exemplo de consulta de carros na Fipe<?php if (!$ codMarca ) {
62
- echo ', clique em uma marca para iniciar ' ;
63
- } ?> .</p>
67
+ echo ', clique em uma marca para iniciar ' ;
68
+ } ?> .</p>
64
69
<table>
65
70
<tr>
66
71
<td valign="top">
You can’t perform that action at this time.
0 commit comments