在php中实现firebase:在firebase中查找令牌

我正在尝试使用php实现firebase,这是我找到的链接:</ p>
\ n

https://github.com/ktamas77/firebase-php </ p >

这是一个例子。</ p>

  const DEFAULT_URL ='https://kidsplace.firebaseio.com/';
const DEFAULT_TOKEN ='MqL0c8tKCtheLSYcygYNtGhU8Z2hULOFs9OKPdEp ';
nbspst DEFAULT_PATH ='/ firebase / example';

$ firebase = new \ Firebase \ FirebaseLib(DEFAULT_URL,DEFAULT_TOKEN);

// ---存储数组---
$ test = array(
“foo”=&gt;“bar”,
“i_love”=&gt;“lamp”,
“id”=&gt; 42
);
$ dateTime = new DateTime();

$ firebase-&gt; set(DEFAULT_PATH。'/'。$ dateTime-&gt; format('c'),$ test);

// ---存储字符串---
$ firebase - &gt; set(DEFAULT_PATH。'/ name / contact001',“John Doe”);

// ---读取存储的字符串---
$ name = $ firebase-&gt; get(DEFAULT_PATH。 '/ name / contact001');
</ code> </ pre>

在这里 是我的相同代码的版本:</ p>

 &lt;?php 

include'firebaseLib.php';

const DEFAULT_URL =“https:// third-try -dae0a.firebaseio.com“;
&nconst DEFAULT_TOKEN ='AIzaSyDeGfW4hnT3a6AXDevJMhb4Pi1eMWQ7yvc';
nbspst DEFAULT_PATH ='/ third-try-dae0a';

$ firebase = new \ Firebase \ FirebaseLib(DEFAULT_URL,DEFAULT_TOKEN); \ n
// ---存储数组---
$ test = array(
“foo”=&gt; “bar”,
“i_love”=&gt; “lamp”,
“id”=&gt; 42
);
$ dateTime = new DateTime();
$ firebase-&gt; set(DEFAULT_PATH。'/'。$ dateTime-&gt; format('c'),$ test);

// ---存储字符串---
$ firebase-&gt; set(DEFAULT_PATH。'/ name / contact001',“John Doe”);

// ---读取存储的字符串 - -

$ name = $ firebase-&gt; get(DEFAULT_PATH。'/ name / contact001');

echo“done”;

?&gt;
</ code> </ pre>

我的代码不起作用... </ p>

</ p>

我只想快速解释一下我在哪里找到DEFAULT_TOKEN </ p>

以及DEFAULT_PATH ?? </ p>
</ div>

展开原文

原文

i am trying to implement firebase with php, here is a link that I found:

https://github.com/ktamas77/firebase-php

and this is an example.

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');

And here is my version of the same code:

<?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";



 ?>

my code doesn't work...

this is where i found my DEFAULT_TOKEN

I just want a quick explanation of where I find the DEFAULT_TOKEN

and what about the DEFAULT_PATH ??

1个回答



1)DEFAULT_PATH </ strong> </ p>

默认路径是您的主项目路径 。 在firebase上创建新项目时。 当你点击它时,你将获得它的路径。 这就像: https://your_project_name-xxx.firebaseio.com </ code> </ p>

2)DEFAULT_TOKEN </ strong> </ p>
\ n

从firebase控制台获取令牌的步骤</ p>

- &gt;登录打开并打开fire base console并选择项目</ p>

- &gt; Go 从设置图标项目 setting </ code> </ p>

- &gt;从菜单中选择 serviceaccounts </ code> </ p>

- &gt;从左侧菜单中选择 databasesecrets </ code> </ p>

- &gt;悬停在秘密上并点击“显示”按钮</ p>
</ div>

展开原文

原文

1) DEFAULT_PATH

Default path is your main project path. When you create new project on firebase. And when you will click on it you will get the path for it. Which is like: https://your_project_name-xxx.firebaseio.com

2)DEFAULT_TOKEN

Steps to get token from firebase console

->login open and open fire base console and select project

->Go to project setting from setting icon

->select serviceaccounts from menu

->select databasesecrets from left menu

->hover on secret and click on show button

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐