2016-09-26 1 views
2

私は、REST APIを実装しているPHPライブラリがあることを知っています:https://github.com/ktamas77/firebase-phpPHPを使用してFirebaseデータベースのデータ変更をどのように聞きますか?

PHPを使用してFirebaseデータベースのデータ変更をどのように聞きますか?

Firebase Databaseの特定のノードでデータの変更を待ち受ける、長時間実行するPHPスクリプトが必要です。 PHPスクリプトは、処理後にデータの変更やFirebaseデータベースへの更新を処理します。

答えて

0

ファイヤーベースのトリガー(機能)をご使用になることをお勧めします。 クラウド機能の作成と展開が可能です。

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. 
    }); 

}); 

注:あなたは(たとえば)サードパーティのWebサービスを呼び出すしたい場合請求を有効にする必要があります。

Cloud Functions for Firebase - Billing account not configured

関連する問題