我点击这个链接是为了删除 Realtime Firebase 上的一个孩子。 https://firebase-php.readthedocs.io/en/stable/realtime-database.html#delete-data
它在本地主机(我的本地开发环境)中工作,但是当我将网站投入生产(使用共享主机)时它不起作用。
我可以用 push() 方法 new child 写,我也可以读,但我不能删除它们。
在我的 Laravel(8) 控制器中,我有类似的东西:
public function __construct()
{
$factory = (new Factory)
->withServiceAccount('./../firebase-realtime-database-credentials.json')
->withDatabaseUri('https://myAppName-xxxxxxx-default-rtdb.firebaseio.com/');
$database = $factory->createDatabase();
/* Comment for the line below: in production, I have to put "/node" instead of just
"node". If not Laravel fire an Exception saying that a path shall start with "/" or be empty. */
$myRef = $database->getReference("node");
}
public function myMethod($key)
{
// When this line is executed no error is fired by Laravel, and the child of remains intact.
$queueRef->getChild($key)->remove();
}
我对 Firebase-Realtime-Database 的规则设置为:
{
"rules": {
".read": "true",
".write": "true",
"node": {
".indexOn": ["priority", "sent", ".value"]
}
}
}
请问有人可以帮忙解决这个问题吗?非常感谢!!!