php - FCM Push Notif script -


i followed tutorial firebase cloud messaging push notifications using android studio. here's tuto : https://www.youtube.com/watch?v=myzvhs6t_w8 got problem push_notification.php :

<?php      function send_notification ($tokens, $message)     {         $url = 'https://fcm.googleapis.com/fcm/send';         $fields = array(              'registration_ids' => $tokens,              'data' => $message             );         $headers = array(             'authorization:key = aaaalxonumg:apa91bgi7qfrl0xvx52kofjfkfzfcezbd6mwwiti7oswmavgn3z9q1toxj9iixixrfc_vb21nrnwnai-vypxcemo5jh53rrfatnjxya5fzaiwonsnly987ephlapy0ijtyw9vlwwopbjsq',             'content-type: application/json'             );        $ch = curl_init();        curl_setopt($ch, curlopt_url, $url);        curl_setopt($ch, curlopt_post, true);        curl_setopt($ch, curlopt_httpheader, $headers);        curl_setopt($ch, curlopt_returntransfer, true);        curl_setopt ($ch, curlopt_ssl_verifyhost, 0);          curl_setopt($ch, curlopt_ssl_verifypeer, false);        curl_setopt($ch, curlopt_postfields, json_encode($fields));        $result = curl_exec($ch);                   if ($result === false) {            die('curl failed: ' . curl_error($ch));        }        curl_close($ch);        return $result;     }      $conn = mysqli_connect("localhost","root","toor","gcm");     $sql = " select token users";     $result = mysqli_query($conn,$sql);     $tokens = array();     if(mysqli_num_rows($result) > 0 ){         while ($row = mysqli_fetch_assoc($result)) {             $tokens[] = $row["token"];         }     }     mysqli_close($conn);     $message = array("message" => " fcm push notification test message");     $message_status = send_notification($tokens, $message);     echo $message_status;  ?> 

and there's result when execute on browser : [http/1.0 500 internal server error 1ms]

my db id's correct, auth key too, problem come ?

$conn = mysqli_connect("localhost","root","toor","gcm"); 

please check these details should (host, dbname, username, password).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -