用于 Firebase HTTP 请求的云函数
Cloud Functions for Firebase HTTP Request
我想从 Android 向云函数发送一个 HTTP 请求,post 一些值,然后将这些值输入实时数据库。
index.js
const functions = require('firebase-functions');
exports.testPost = functions.https.onRequest((req, res) => {
console.log(req.body);
});
我怎样才能做到这一点?
我在这里看到三个步骤:
正在从 Android.
调用云函数
这与从 Android 调用任何其他 HTTP URL 相同。看
正在从您的云函数中的调用解析参数
HTTP 触发的 Cloud Function 实际上只是一个 Express 处理程序。因此解析 post 的工作方式与其他 Express 处理程序相同。 Firebase documentation for HTTP functions 有一些示例和指向其他文档的链接。
从 Cloud Functions 发布到数据库
functions-samples repo include the Firebase Admin SDK. This SDK allows you to access many Firebase features, such as the database, from within your function. But there's also an example in this repo.
中的所有样本
我想从 Android 向云函数发送一个 HTTP 请求,post 一些值,然后将这些值输入实时数据库。
index.jsconst functions = require('firebase-functions');
exports.testPost = functions.https.onRequest((req, res) => {
console.log(req.body);
});
我怎样才能做到这一点?
我在这里看到三个步骤:
正在从 Android.
调用云函数这与从 Android 调用任何其他 HTTP URL 相同。看
正在从您的云函数中的调用解析参数
HTTP 触发的 Cloud Function 实际上只是一个 Express 处理程序。因此解析 post 的工作方式与其他 Express 处理程序相同。 Firebase documentation for HTTP functions 有一些示例和指向其他文档的链接。
从 Cloud Functions 发布到数据库
functions-samples repo include the Firebase Admin SDK. This SDK allows you to access many Firebase features, such as the database, from within your function. But there's also an example in this repo.
中的所有样本