duan35557593 2017-08-23 08:55
浏览 171
已采纳

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

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条回答

  • drvvvuyia15070493 2017-08-23 09:03
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧