// fcm_helper.php function sendFCMNotification($tokens, $title, $body) { $url = 'https://fcm.googleapis.com/fcm/send'; $serverKey = 'YOUR_SERVER_KEY'; $headers = [ 'Authorization: key=' . $serverKey, 'Content-Type: application/json' ]; $data = [ "registration_ids" => $tokens, "notification" => [ "title" => $title, "body" => $body ] ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $result = curl_exec($ch); curl_close($ch); return $result; }