2017-08-23 1 views
0

ich versuche, mit php Feuerbasis zu implementieren, hier ist ein Link, den ich gefunden:Implementierung von Feuerbasis in php: Suche nach Token in Feuerbasis

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

und dies ist ein Beispiel dafür.

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

Und hier ist meine Version des gleichen 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"; 



?> 

mein Code funktioniert nicht ...

this is where i found my DEFAULT_TOKEN

Ich möchte nur eine kurze Erklärung, wo ich finde die DEFAULT_TOKEN

und was ist mit dem DEFAULT_PATH ??

Antwort

4

1) DEFAULT_PATH

Standardpfad ist Ihr Hauptprojektpfad. Wenn Sie ein neues Projekt auf Firebase erstellen. Und wenn Sie darauf klicken, erhalten Sie den Pfad dafür. Welches ist wie: https://your_project_name-xxx.firebaseio.com

2) DEFAULT_TOKEN

Schritte zum erhalten von Feuerbasis Konsole Token

-> login offen und offene Feuer Basiskonsole und wählen Sie Projekt

-> zum Projekt gehen setting vom Einstellungssymbol

-> wählen Sie serviceaccounts aus dem Menü

-> wählen databasesecrets von links Menü

-> schweben auf geheime und klicken Sie auf Show-Taste