如何使用 firebase 调用第三方 API?

How do I call third party APIs from with firebase?

这可能是个愚蠢的问题, 我有一个 api 用于验证数据和做一些自定义的事情

可以从 firebase

的验证规则中调用这个 api
 {
   "rules": {
      ".read": "true",
     //is it possible to do like this
      ".validate": "ajaxCall(Url/to/api/returns/bool)"
    }
 }

或者什么是最适合第三方 api 与 firebase 集成的方式

我正在使用 angularJs、bootstrap、firebase

您只能访问 Firebase 为您提供的预定义服务器变量。这里是 a list from the documentation.

如果您想与第三方集成 API,您将需要 运行 一个服务器。

对于实时流式传输,您可以使用 node.js client or JVM client. If you chose the JVM client, you can host it on AppEngine (which is really easy to maintain). This tutorial is really, really good

如果您选择 node.js 客户端,您可以执行如下操作。

var ref = new Firebase('<my-firebase-app>/purchases/user_1');
// Create a listener for every time something is added
ref.on('child_added', function(snap) {

  // When something is added, make the ajax call
  ajaxCall('url/to/api/returns/bool', function(error, data) {
     // take action from 3rd party API here
  });

});