-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransactions2.php
More file actions
executable file
·71 lines (53 loc) · 1.88 KB
/
Copy pathtransactions2.php
File metadata and controls
executable file
·71 lines (53 loc) · 1.88 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class ValueOfCar {
private $api_key = "j9s2gskzgc3e9zc2b4huur75";
function priceOfCar($UVC, $state, $mileage, $quality )
{
$url = "http://autoAPI.hearst.com/v1/UsedCarWS/UsedCarWS/UsedVehicle/UVC/" . $UVC . "?state=" . $state . "&mileage=". $mileage . "&api_key=" . $this->api_key;
$response=$this->_connectAPI($url);
if($quality == "xclean")
{
$price = $response->used_vehicles->used_vehicle_list[0]->retail_xclean;
}elseif($quality == "clean")
{
$price = $response->used_vehicles->used_vehicle_list[0]->retail_clean;
}elseif($quality == "avg")
{
$price = $response->used_vehicles->used_vehicle_list[0]->retail_avg;
}elseif($quality == "rough")
{
$price = $response->used_vehicles->used_vehicle_list[0]->retail_rough;
}
return $price;
}
private function _connectAPI($url) {
$ch = curl_init();
$opts = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json'
)
);
curl_setopt_array($ch, $opts);
$response = curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
$response = json_decode($response);
return $response;
}
}
//$test = new ValueOfCar();
// print_r($test->priceOfCar(2010900249, "MI", 500000, "avg"));
//$car=new ValueOfCar();
//print_r($test->priceOfCar($uvc, "MN", 500000, "avg"));
if($_POST['uvc']!=""){
$uvc=$_POST['uvc'];
$state=$_POST['state'];
$mileage=$_POST['mileage'];
$condition=$_POST['condition'];
$carValue=new ValueOfCar();
echo " ".$carValue->priceOfCar($uvc, $state, $mileage, $condition);
}
?>