有没有一个非缩小的JavaScript版本的FireBase API? [英] Is there a un-minified JavaScript version of the FireBase API?
问题描述
我正在为通过FireBase提供API的设备开发一个接口,但我并不是使用Java,JavaScript或FireBase提供的任何其他语言工作。
我正在使用Lua,虽然我可以轻松实现REST API,但我希望能够像firebase.js提供的那样使用WebSocket API。
我可以创建WebSocket连接,但不知道授权功能如何在firebase.js中工作,并且想知道是否有未精简版的firebase.js,所以我可以看到身份验证调用起作用。
Firebase用于与客户端库进行通信的协议不是有记录的API。您可能可以对其进行反向工程,但由于它不是一个记录的API,因此它可能会随时更改。您可能需要调查Firebase的 REST Streaming ,它允许您监听对位置。下面是一个服务器可以发送的例子,根据文档:
//将整个缓存设置为{a: 1,b:2}
事件:放
data:{path:/,data:{a:1,b:2}}
//将新数据放入缓存中的'c'下,这样完整的缓存现在看起来像:
// {a:1,b:2,c: {foo:true,bar:false}}
event:put
data:{path:/ c,data:{foo:true,bar此外,@Anant在其评论中提到的Firebase客户端是已弃用的版本这是非常古老的。
I'm working on an interface for a device who provides an API through FireBase, but I'm not working in Java, JavaScript, or any other language FireBase provides libraries for.
I'm using Lua, and while I can easily implement the REST API, I'd like to be able to use the WebSocket API, as firebase.js provides.
I can create a WebSocket connection, but don't know how the authorization functionality works in firebase.js, and was wondering if there's an 'un-minified' version of firebase.js, so I can see how the authentication call works.
解决方案 The protocol that Firebase uses to communicate with its client libraries is not a documented API. You might be able to reverse engineer it, but since it's not a documented API, it could change at any time.
You may want to investigate Firebase's REST Streaming, which allows you to listen for changes to a location. Here's an example of what the server could send, per the docs:
// Set your entire cache to {"a": 1, "b": 2}
event: put
data: {"path": "/", "data": {"a": 1, "b": 2}}
// Put the new data in your cache under the key 'c', so that the complete cache now looks like:
// {"a": 1, "b": 2, "c": {"foo": true, "bar": false}}
event: put
data: {"path": "/c", "data": {"foo": true, "bar": false}}
Also, the Firebase client that @Anant mentions in his comment is a deprecated version that's very old.
这篇关于有没有一个非缩小的JavaScript版本的FireBase API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!