0
PHPからAndroid Appに通知を送信しようとしています。私のPHPコードはここにあります。PHP + Android CURL Firebase通知エラー
<?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;
?>
と私はFireBaseコンソールからの通知を送信できます。そしてサーバーIDコードは正しいです。私は何が問題なのですか?この問題を解決するための助言や方法はありますか?ありがとうございます...
通常、50xエラーは問題がサーバー側にあることを意味します。 https://firebase.google.com/support/ – pawelo
取得しているダウンストリームメッセージレスポンス本文には、[documentation](https://firebase.google)で定義されているフィールドの一部が含まれていません。 .com/docs/cloud-messaging/http-server-ref#interpret-downstream)@paweloが推奨するfirebaseのサポートに連絡する方がよいでしょう。 – GeorgeLBA