2
我知道有一個PHP庫實現REST API:https://github.com/ktamas77/firebase-php如何使用PHP在Firebase數據庫上偵聽數據更改?
如何使用PHP在Firebase數據庫上偵聽數據更改?
由於我需要一個長時間運行的PHP腳本來監聽Firebase數據庫中特定節點上的數據更改。 PHP腳本將處理數據更改並在處理後更新到Firebase數據庫。
我知道有一個PHP庫實現REST API:https://github.com/ktamas77/firebase-php如何使用PHP在Firebase數據庫上偵聽數據更改?
如何使用PHP在Firebase數據庫上偵聽數據更改?
由於我需要一個長時間運行的PHP腳本來監聽Firebase數據庫中特定節點上的數據更改。 PHP腳本將處理數據更改並在處理後更新到Firebase數據庫。
我建議您爲您的請求使用firebase觸發器(函數), 您可以創建並部署您的雲功能。
火力地堡觸發: https://firebase.google.com/docs/functions/write-firebase-functions
節點JS請求: https://www.npmjs.com/package/request
例如:
const functions = require('firebase-functions');
const request = require('request');
exports.setWriteServiceStatus = functions.database.ref('/').onWrite(event => {
// API Url : http://www.amirhome.com
request('http://www.amirhome.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
});
注意:如果你想叫第三方網絡服務(例如)您需要啓用計費。
Cloud Functions for Firebase - Billing account not configured