title: How to implement web push notifications using FCM in php
body: <p>I'm working on web push notifications using service worker. But I struck while sending notifications from server using FCM(Firebase Cloud Messaging). Here is my php script and I'm not getting how should I call this in service worker. Please guide me. </p>
  
  <pre><code>define( 'API_ACCESS_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
  $msg = array(
                 'message'       =&gt; 'Wakeup Wakeup!!',
                 'title'         =&gt; 'Wakeup call !',
              );
  $fields = array(
            'registration_id'  =&gt; xxxxxxxxxx,
            'data'              =&gt; $msg
           );
  $headers = array
             (
              'Authorization: key=' . API_ACCESS_KEY,
              'Content-Type: application/json'
              );
  
  $ch = curl_init();
  curl_setopt( $ch,CURLOPT_URL, '//gcm-http.googleapis.com/gcm/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;
  </code></pre>