am trying to send server notification via firebase to my android apps. I am using xampp local server to test firebase notification from app server. I have followed some tutorial and i have done all the things. my app showing notification from firebase solely, but when i am trying to show notification from app server via firebase its showing `**
The request was missing an Authentication Key (FCM Token). Please, refer to section "Authentication" of the FCM documentation, at https://firebase.google.com/docs/cloud-messaging/server.
` i have tried with adding **server key: AAAAX2m5UCk:********************************************************************n
Also with Legacy server key AI********************D8
my php code to send notification:
<?php
require "init.php";
$message = $_POST['message'];
$title=$_POST['title'];
$path_to_fcm = 'https://fcm.googleapis.com/fcm/send';
$server_key="AAAAX2m5UCk:*********n";
$sql="select fcm_token from fcm_info";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_row($result);
$key = $row[0];
// var_dump($key);
$fields = array('to' => $key,'data' =>array('title' => $title,'body'=>$message));
$payload = json_encode($fields);
$headers = array(
"Content-Type: application/json",
"Athorization: key=$server_key"
);
// die();
$curl_session = curl_init();
curl_setopt($curl_session, CURLOPT_URL, $path_to_fcm);
curl_setopt($curl_session, CURLOPT_POST, true);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_session, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($curl_session, CURLOPT_POSTFIELDS, $payload);
$result = curl_exec($curl_session);
if(curl_error($curl_session))
{
echo 'error:' . curl_error($curl_session);
}
curl_close($curl_session);
var_dump($result);
// myqsli_close($con);
?>