Preview: burq.php
Size: 4.71 KB
/home/godevadmin/public_html/include/burq.php
<?php
error_reporting(E_ALL);
//Configuration
define('burq_quote',"https://api.burqup.com/v1/quote");
define('burq_create_delivery',"https://api.burqup.com/v1/delivery_information");
define('burq_initiate_delivery',"https://api.burqup.com/v1/initiate_delivery");
define('burq_get_single_delivery',"https://api.burqup.com/v1/delivery/");
define('burq_list_delivery',"https://api.burqup.com/v1/deliveries");
if(SITE_URL=='https://www.quicklly.com'){
//prod
define('burq_key',"715c1c75-5a13-40c4-992f-52e91cf0b24b");
}else{
//sandbox
define('burq_key',"3c55c184-d8ea-47e4-aef3-1ab7d14a70b4");
}
//echo burq_key;
function curl_response($curl){
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return $err;
} else {
return $response;
}
}
function burqquote($pickup,$dropoff){
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => burq_quote,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"pickup_address\":\"$pickup\",\"dropoff_address\":\"$dropoff\"}",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Content-Type: application/json",
"x-api-key: ".burq_key,
],
]);
return curl_response($curl);
}
//burqquote('125 Western Ave, Allston, MA, 02134','127 Western Ave, Allston, MA, 02134');
function create_delivery($pickup,$dropoff,$item_list,$d_name,$d_phone,$d_notes,$p_name,$p_phone,$p_notes,$tip,$order_desc,$order_id){
$item_list=json_encode($item_list);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => burq_create_delivery,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"items\":$item_list,\"pickup_address\":\"$pickup\",\"dropoff_address\":\"$dropoff\",\"dropoff_name\":\"$d_name\",\"pickup_name\":\"$p_name\",\"dropoff_phone_number\":\"+1$d_phone\",\"pickup_phone_number\":\"+1$p_phone\",\"dropoff_notes\":\"$d_notes\",\"pickup_notes\":\"$p_notes\",\"tip\":$tip,\"items_description\":\"$order_desc\",\"external_order_ref\":\"order #$order_id\"}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: ".burq_key,
],
]);
return curl_response($curl);
}
//create_delivery('125 Western Ave, Allston, MA, 02134','127 Western Ave, Allston, MA, 02134');
function initiate_delivery($identifier){
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => burq_initiate_delivery,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"deliveryInfoId\":\"$identifier\"}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: ".burq_key,
],
]);
return curl_response($curl);
}
//initiate_delivery('40efp38jl1x8rzhw');
function get_single_delivery($identifier){
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => burq_get_single_delivery.$identifier,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: ".burq_key,
],
]);
return curl_response($curl);
}
function cancel_delivery($identifier){
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => burq_initiate_delivery.$identifier."/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-api-key: ".burq_key,
],
]);
return curl_response($curl);
}
function list_delivery(){
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => burq_list_delivery,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: ".burq_key,
],
]);
return curl_response($curl);
}
?>
Directory Contents
Dirs: 1 × Files: 25