0
Winifred posted
Error 401 INVALID_KEY_TYPE FireBase with PHP
$url = "https://fcm.googleapis.com/fcm/send";
$token = $devicetoken;
$serverKey = 'BVhFT_kT43i-DHZt6fQBVhFT_kT43i-DHZt6fQ';
$title =$title;
$body = $body;
$notification = array('title' =>$title , 'body' => $body, 'sound' => 'default', 'badge' => '1');
$arrayToSend = array('to' => $token, 'notification' => $notification,'priority'=>'high');
$json = json_encode($arrayToSend);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: key='. $serverKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
//Send the request
$response = curl_exec($ch);
print_r($response);
//Close request
if ($response === FALSE) {
die('FCM Send Error: ' . curl_error($ch));
}
curl_close($ch);
i am getting error : INVALID_KEY_TYPE so not sure what is wrong in the firebase API call for FCM notification