Android Question PHP firebase invalid key type error

Reminisce

Active Member
Hello gurus, I'm calling this php script from my app after performing an action. But I keep getting the error 401,and my api key is the same as my web api key on my dashboard. I'm confused as it is.
Php code:
<?php // API access key from Google API's Console

define('API_ACCESS_KEY', 'AIzaSyDvkIrQby4Zz_9YMGYwkUQ0Tjqft#####w');

 

 $receiver = $_POST['receiver'];

 $body = $_POST['body'];

 $title= $_POST['title'];

 // prep the bundle

 $msg = array ( 'body' => $body,

 'title' => $title );

 $fields = array ( 'to' => '/topics/'.$receiver, 'notification' => $msg );

 

$headers = array

(

    'Authorization: key=' . API_ACCESS_KEY,

    'Content-Type: application/json'

);

 $ch = curl_init();

 curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );

 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( $fields ) );

 $result = curl_exec($ch );

 curl_close( $ch );

 echo $result;

 ?>
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…