I'm trying to send a notification from PHP to Android App. My PHP CODES are here.
<?php
require "int.php";
$message = $_POST['message'];
$title = $_POST['title'];
$path_to_fcm = 'https://fcm.googleapis.com/fcm/send';
$server_key = "1:485869546397:android:bd503a78b6c26c35";
$sql = "select fcm_token from fcm_info";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_row($result);
$key = $row[0];
$headers = array(
'Authorization:key=' .$server_key,
'Content-Type:application/json'
);
$fields = array('to'=>$key,
'notification'=>array('title'=>$title,'body'=>$message));
$payload = json_encode($fields);
echo $payload;
$curl_session = curl_init();
curl_setopt($curl_session, CURLOPT_URL, $path_to_fcm);
curl_setopt($curl_session, CURLOPT_POST, true);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_session, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($curl_session, CURLOPT_POSTFIELDS, $payload);
$result = curl_exec($curl_session);
echo $result;
?>
and i post a data to mycode i give an this output :
And i can send a notification from FireBase Console. And Server id code is correct.I could not what is the matter ? Can you give an advice or any way to solve this problem ? Thank you...