嗨,我正在我的代码点火器项目中集成firebase PHP SDK,当我调用我的api时,它通过错误消息:在null 上调用成员函数getReference((
我的代码是:
<?php
use KreaitFirebaseFactory;
$factory = (new Factory)->withServiceAccount(APPPATH.'config/globaltaxi-277114-firebase-adminsdk-5s93b-2a0246ed22.json');
$database = $factory->createDatabase();
//$firebase->set($uri, $);
$ci = &get_instance();
function AddDriverToFirbase($uri, $driver_string)
{
$ci = &get_instance();
$firebaseDBComUrl = $ci->config->item('firebase_url');
$fireBaseNewRoomStorePath = $firebaseDBComUrl; //.$uri;
$database->getReference($fireBaseNewRoomStorePath)->getChild($uri)->set($driver_string);
}
错误响应为遇到未捕获的异常类型:错误
消息:在空上调用成员函数getReference((
你能帮我解决这个问题吗。谢谢
首先我检查了我的php版本,并根据版本更新了sdk,之后解决了所有与lib相关的问题。
发现了关于uri的问题,我需要更新如下:
$database->getReference($uri)->set($driver_string);
意味着不需要所有的url,只需要添加节点名,我们需要使用哪个来添加我们的数据。