title: Firebase notification PHP script
body: <p>I'm testing firebase notification since my old project was integrated to GCM, but now I'm also using firebase database.</p>
  
  <p>I'm trying to execute a php script in order to send notification to one of my device. I'm able to obtain the <code>TokenID</code> and also I'm able to send notifications to this token from the Firebase Console, but when I use the PHP script, I have the following error:</p>
  
  <blockquote>
    <p>Invalid (legacy) Server-key delivered or Sender is not authorized to perform request.</p>
  </blockquote>
  
  <p>Here is my script:</p>
  
  <pre><code>$message = $_POST['message'];
  $title = $_POST['title'];
  $path_to_fcm = 'https://fcm.googleapis.com/fcm/send';
  $server_key = "AAAXXXXXX";
  $key =  "c43xxxxxxxxx";
  
  
  $headers = array (
      'Authorization: key =' . server_key,
      'Content-Type:application/json'
  );
  
  $fields = array('to'=&gt;$key,
              'notification'=&gt;array('title'=&gt;$title,'body'=&gt;$message));
  
  $payload = json_encode($fields);
  
  $curl_session = curl_init();
  curl_setopt($curl_session, CURLOPT_URL, $path_to_fcm);
  curl_setopt($curl_session, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl_session, CURLOPT_POSTFIELDS, $payload);
  curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, "POST"); 
  
  $result = curl_exec($curl_session);
  curl_close($curl_session);
  
  echo $result;
  </code></pre>
  
  <p>I'm getting the api key from:</p>
  
  <pre><code>Firebase console &gt; gear icon &gt; proyect configuration &gt; Cloud messaging
  </code></pre>