gpt4 book ai didi

php - Firebase 错误 : Credentials fetcher does not implement Google\Auth\UpdateMetadataInterface

转载 作者:行者123 更新时间:2023-12-03 20:24:03 30 4
gpt4 key购买 nike

请我尝试从 PHP 中的 firebase 获取数据,它给了我这个错误

Uncaught RuntimeException: Credentials fetcher does not implement Google\Auth\UpdateMetadataInterface
这是我的代码:
require_once 'vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;

$db = new FirestoreClient([
'projectId' => 'firebase-db-name'
]);


$docRef = $db->collection('collection')->document('document');
$snapshot = $docRef->snapshot();

if ($snapshot->exists()) {
printf('Document data:' . PHP_EOL);
print_r($snapshot->data());
} else {
printf('Document %s does not exist!' . PHP_EOL, $snapshot->id());
}
请问我做错了什么,或者我想将什么导入到代码中才能让它工作并停止给我错误

最佳答案

我为我工作
'project_Id' => 'firebase-db-name',
'keyFile' => json_decode(file_get_contents('./file.json'), true)
get KeyFile = Firebase Console/Project Settings/Service accounts/Firebase admin SDK/-> Generate new private key
然后下载它并用 file.json 过去它
百分比:100% 成功

关于php - Firebase 错误 : Credentials fetcher does not implement Google\Auth\UpdateMetadataInterface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64954849/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com