[英]implementation of firebase in php: finding token in firebase
我正在尝试用 php 实现 firebase,这是我找到的一个链接:
https://github.com/ktamas77/firebase-php
这是一个例子。
const DEFAULT_URL = 'https://kidsplace.firebaseio.com/';
const DEFAULT_TOKEN = 'MqL0c8tKCtheLSYcygYNtGhU8Z2hULOFs9OKPdEp';
const DEFAULT_PATH = '/firebase/example';
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
// --- storing an array ---
$test = array(
"foo" => "bar",
"i_love" => "lamp",
"id" => 42
);
$dateTime = new DateTime();
$firebase->set(DEFAULT_PATH . '/' . $dateTime->format('c'), $test);
// --- storing a string ---
$firebase->set(DEFAULT_PATH . '/name/contact001', "John Doe");
// --- reading the stored string ---
$name = $firebase->get(DEFAULT_PATH . '/name/contact001');
这是我的相同代码的版本:
<?php
include 'firebaseLib.php';
const DEFAULT_URL = "https://third-try-dae0a.firebaseio.com";
const DEFAULT_TOKEN = 'AIzaSyDeGfW4hnT3a6AXDevJMhb4Pi1eMWQ7yvc';
const DEFAULT_PATH = '/third-try-dae0a';
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
// --- storing an array ---
$test = array(
"foo" => "bar",
"i_love" => "lamp",
"id" => 42
);
$dateTime = new DateTime();
$firebase->set(DEFAULT_PATH . '/' . $dateTime->format('c'), $test);
// --- storing a string ---
$firebase->set(DEFAULT_PATH . '/name/contact001', "John Doe");
// --- reading the stored string ---
$name = $firebase->get(DEFAULT_PATH . '/name/contact001');
echo "done";
?>
我的代码不起作用...
我只想快速解释我在哪里找到 DEFAULT_TOKEN
DEFAULT_PATH 呢??
1) DEFAULT_PATH
默认路径是您的主要项目路径。 当您在 firebase 上创建新项目时。 当您单击它时,您将获得它的路径。 就像: https://your_project_name-xxx.firebaseio.com
: https://your_project_name-xxx.firebaseio.com
2)DEFAULT_TOKEN
从 Firebase 控制台获取令牌的步骤
->登录打开并打开firebase控制台并选择项目
->从设置图标转到项目setting
-> 从菜单中选择serviceaccounts
-> 从左侧菜单中选择databasesecrets
-> 将鼠标悬停在秘密上并单击显示按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.