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);
 }
示例#2
0
 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);
 }
示例#3
0
 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'];
 }
示例#4
0
 public function changePassword(TDispatch $td, $requestBody)
 {
     $data = array("key" => $td->getApiKey());
     $url = $td->getFullApiUrl() . 'accounts/change-password?' . http_build_query($data);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, count($requestBody));
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     if ($td->debug) {
         error_log(__FILE__ . ' in line ' . __LINE__);
         error_log(__CLASS__ . ' in method ' . __METHOD__);
         error_log("URL: " . $url);
         error_log("DATA BODY: " . json_encode($requestBody));
     }
     $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 true;
 }
示例#5
0
 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'];
 }