,因爲我可以看到谷歌不支持捲曲實現,我必須遠離捲曲的實現,因爲我在後已經解釋移動 - [FCM could not be sent on GAE due to PHP error - call to undefined function curl_init()FCM - 實現從curl_init()在GAE遠
我想爲網址以谷歌雲平臺文檔中提供的示例爲例 - [https://cloud.google.com/appengine/docs/standard/php/issue-requests][1]
儘管如此,我仍然無法打破由於PHP知識欠缺而無法使用FCM的障礙。
下面,是我一直嘗試 -
<?php
// Establishing FCM connection here to send a token received over to another device.
function send_fcm_notification_url_fetch ($tokens,$message) {
$url = "https://fcm.googleapis.com/fcm/send";
$fields = array('registration_ids' => '<device_token_id>',
'data' => 'Hi');
$queryParam = http_build_query($fields);
$headers = array('Authorization:key = <firebase_server_key>',
'Content-Type: application/json');
$context = array('http' => array('method' => 'POST', 'header' => $headers, 'content' => $queryParam));
$context = stream_context_create($context);
$result = file_get_contents($url,false,$context);
echo $result;
return $result;
}
?>
但是,儘管上面,我得到下面的錯誤 -
警告:的file_get_contents(https://fcm.googleapis.com/fcm/send):未能打開流:HTTP請求失敗!在線##上的D:\ wamp64 \ www \ androidtrials \ send_fcm_notification_url_fetch.php中的HTTP/1.0 400錯誤請求。
我不確定發生了什麼問題。通過多次搜索,但沒有讓我滿足我的要求。 有沒有人使用PHP完成FCM消息傳遞,但不使用捲曲?感謝您的關注,尋求幫助。