forked from rafavinnce/fast-tech-review
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
49 lines (40 loc) · 1.19 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
function get($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$saida = curl_exec($curl);
curl_close($curl);
return $saida;
}
header('Content-Type: application/json');
$filtro0 = 'abv_gt=4';
$filtro1 = 'abv_lt=4';
$filtro2 = 'ibu_gt=40';
$filtro3 = 'ibu_lt=35';
$filtro4 = 'ebc_gt=8';
$filtro5 = 'ebc_lt=8';
$filtroName = 'beer_name=Buzz';
switch ($_REQUEST['filtro']){
case 0:
echo get('https://api.punkapi.com/v2/beers?'.$filtro0);
break;
case 1:
echo get('https://api.punkapi.com/v2/beers?'.$filtro1);
break;
case 2:
echo get('https://api.punkapi.com/v2/beers?'.$filtro2);
break;
case 3:
echo get('https://api.punkapi.com/v2/beers?'.$filtro3);
break;
case 4:
echo get('https://api.punkapi.com/v2/beers?'.$filtro4);
break;
case 5:
echo get('https://api.punkapi.com/v2/beers?'.$filtro5);
break;
case 6:
echo get('https://api.punkapi.com/v2/beers?'.$filtroName);
break;
}