/home/desid573/public_html/test_api
Edit: /home/desid573/public_html/test_api/send_bulk_notif.php (1692B)
query($sql);
while($row_details = $result->fetch_assoc())
{
$firebase_token = $row_details["firebase_token"] ;
if($firebase_token != "") {
$headers = array
(
'Authorization: key='.$authkey,
'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": "Melbourne Cup Day",
"body": "We are very busy on Melbourne Cup Day between 4pm and 7pm so if you will require a driver please consider booking in advance.",
"sound": "mySound"
},
"to" : "'.$firebase_token.'"
}');
$response = curl_exec($curlObj);
curl_close($curlObj);
$firebase_result = json_decode($response, true);
error_log($response);
if($firebase_result['failure'] != 1) {
echo "Notification sent to ".$row_details['name']." at ".date("h:i:sa");
} else {
echo "Error sending to ".$row_details['name'];
}
}
}
$conn->close();
// =============== New customer user api End Here ==========================
?>