/home/desid573/public_html/angel
Edit: /home/desid573/public_html/angel/confirmsend.php (2582B)
query($sql);
if ($result->num_rows > 0) {
while($row_details = $result->fetch_assoc()) {
$booking_detail[] = $row_details;
}
$sql = "SELECT * FROM `customers` where id = '".$booking_detail[0]['cid']."'";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row_detail = $result->fetch_assoc())
{
$booking_details[] = $row_detail;
}
}
$firebase_token = $booking_details[0]['firebase_token'];
$phone = $booking_details[0]['mobile'];
}
if($check=="check" && !empty($ref)) {
if($booking_detail[0]['status'] == "") {
echo "no";
} else {
echo "yes";
}
}
if($check=="send" && !empty($ref)) {
$sql = "UPDATE booking SET status='confirmed' WHERE id='".$ref."'";
$result = $conn->query($sql);
$headers = array
(
'Authorization: key=AAAAmOGb3vM:APA91bE-XimrlXCGEycGTB2YOV1kWQ-fFCyjKvgtz74yX1WqGUP84sQxzlR7ESqzcEHcHquR2EYWBJZuIazbe0wkpsAEQSRxIWoFPP20U5OfyILQ7zaGYIoXm3SSdCRVj4U332cxIn_I',
'Content-Type: application/json'
);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, '{ "notification": {
"title": "Booking has been confirmed",
"body": "Your booking is confirmed, a driver will be dispatched shortly",
"sound": "mySound"
},
"to" : "'.$firebase_token.'"
"data": {
"status": "confirmed",
"bid": '.$ref.'
}
}');
$response = curl_exec($curlObj);
curl_close($curlObj);
error_log($response);
$result = json_decode($response, true);
if($result['failure'] == 1) {
$account_sid = 'AC1b4db66d86197058950ad349a2327a85';
$auth_token = '053ae80d10eac3b60c92179d3492badf';
$client = new Client($account_sid, $auth_token);
$messages = $client->messages->create("$phone", array('From' => "DesiDrivers", 'body' => 'Your booking is confirmed, you will be notified when a driver is assigned'));
if($messages) {
echo "yes";
} else {
echo "no";
}
} else {
echo "yes";
}
}