Commit 0a6e2ead by Tobin

dc

parent 5a0ef2d5
...@@ -4,6 +4,12 @@ $conn = mysqli_connect("localhost","nuvento_timeout","Golden_123","nuvento_timeo ...@@ -4,6 +4,12 @@ $conn = mysqli_connect("localhost","nuvento_timeout","Golden_123","nuvento_timeo
if($conn->connect_error){ if($conn->connect_error){
return; return;
} }
$result = mysqli_query($conn, "SELECT app_id FROM setting");
if(mysqli_num_rows($result) <= 0 || empty($row = mysqli_fetch_assoc($result)) ||
!isset($row['app_id']) || empty($key = $row['app_id'])){
return;
}
$date = date('Y-m-d',strtotime(date("Y-m-d H:i:s")." +30 minutes")); $date = date('Y-m-d',strtotime(date("Y-m-d H:i:s")." +30 minutes"));
$sTime = date('H:i',strtotime(date("Y-m-d H:i:s")." +30 minutes")); $sTime = date('H:i',strtotime(date("Y-m-d H:i:s")." +30 minutes"));
...@@ -22,17 +28,22 @@ $result = mysqli_query($conn, $sql); ...@@ -22,17 +28,22 @@ $result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0) { if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) { while($row = mysqli_fetch_assoc($result)) {
print_r($row);
} $data = "{ \"notification\": { \"title\": \"".$row['event_name']."\", \"text\": \"Booking Remainder\", \"sound\": \"default\" }, \"time_to_live\": 60, \"data\" : {\"response\" : {\"status\" : \"success\", \"data\" : {\"booking_id\" : \"".$row['bookId']."\", \"trip_status\" : 0}}}, \"collapse_key\" : \"trip\", \"priority\":\"high\", \"to\" : \"".$row['fcm_token']."\"}";
exit;
foreach($bookData AS $bData){ $ch = curl_init("https://fcm.googleapis.com/fcm/send");
$userData = array('id'=>$bData['bookId'], $header = array('Content-Type: application/json', 'Authorization: key='.$key);
'title'=>$bData['event_name'], curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
'message'=>'Booking Remainder'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$this->push_sent_cancel('2',$bData['fcm_token'],$userData); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$out = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
} }
$this->db->insert('crontab_notif',array('date'=>date('Y-m-d'),'time'=>date('H:i:s'))); mysqli_query($conn, "INSERT INTO crontab_notif VALUES ('',".date('Y-m-d').",".date('H:i:s').")");
} }
$conn->close(); $conn->close();
?> ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment