public function fare(TDispatch $td, $pickup_postcode, $dropoff_postcode, $pickup = array(), $dropoff = array(), $waypoints = array()) { $data = array("access_token" => $td->getToken()); $url = $td->getFullApiUrl() . 'locations/fare?' . http_build_query($data); $ch = curl_init(); $dataSend = array('pickup_postcode' => $pickup_postcode, 'dropoff_postcode' => $dropoff_postcode, 'pickup_location' => $pickup, 'dropoff_location' => $dropoff, 'waypoints' => $waypoints); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($dataSend)); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataSend)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); return json_decode($result, true); }
public function vehicles_list(TDispatch $td, $limit = 4) { $data = array("access_token" => $td->getToken()); $url = $td->getFullApiUrl() . 'vehicletypes?' . http_build_query($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); $res = json_decode($result, true); $info = curl_getinfo($ch); curl_close($ch); if (!isset($res['status']) || $res['status'] !== 'OK') { $td->setError($res); return false; } return array_slice($res['vehicle_types'], 0, $limit); }
public function nearby(TDispatch $td, $limit, $location, $radius, $offset) { $data = array("access_token" => $td->getToken()); $url = $td->getFullApiUrl() . 'drivers/nearby?' . http_build_query($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); $dataSend = array('limit' => $limit, 'location' => $location, 'radius' => $radius, 'offset' => $offset); curl_setopt($ch, CURLOPT_POST, count($dataSend)); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataSend)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); $res = json_decode($result, true); $info = curl_getinfo($ch); curl_close($ch); if (!isset($res['status']) || $res['status'] !== 'OK') { $td->setError($res); return false; } return $res['drivers']; }
public function getFleetdata(TDispatch $td) { $data = array("access_token" => $td->getToken()); $url = $td->getFullApiUrl() . 'accounts/fleetdata?' . http_build_query($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); return json_decode($result, true); }
public function Bookings_customfields(TDispatch $td) { $data = array("access_token" => $td->getToken()); $url = $td->getFullApiUrl() . 'bookings/custom-fields?' . http_build_query($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); $res = json_decode($result, true); $info = curl_getinfo($ch); curl_close($ch); if (!isset($res['status']) || $res['status'] !== 'OK') { $td->setError($res); return false; } return $res['custom_fields']; }