i got a app using fcm to notificantions and all works fine when i send messages via the console, but when i try to send via php(curl post) or postman(firefox extension) i got a auth error(even using the key)
string(304) "{ "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } } "
i got the key from the firebase project console my php code is
public function send_FCM(){
// Method - 1
$fcmUrl = 'https://fcm.googleapis.com/v1/projects/anal.........719/messages:send';
$notification = array(
"to"=>"/topic/cidade396",
"notification"=>array(
"body"=>"test 123"
)
);
$headers = [
'Authorization: key=AIz.........9KWwy5BisxXYbA8',
'Content-Type: application/json'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$fcmUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($notification));
$result = curl_exec($ch);
curl_close($ch);
var_dump($result);
return true;
} anyone know how can i solve this?