尝试从PHP访问

时间:2019-02-11 06:12:17

标签: php google-cloud-firestore

尝试从PHP访问Cloud Firestore。我相信我已经正确设置了所有内容,并且它似乎正在接受我的授权文件,并且到达了快照行的最远位置,但是随后引发错误“该项目未启用Cloud Firestore API”。我有一个单独的javascript网页,可以毫无问题地访问该数据库;试图构建一个页面用于PHP且不能克服此错误的其他目的。任何帮助将不胜感激...

putenv("GOOGLE_APPLICATION_CREDENTIALS=c:/XXX/google-auth.json");
require '/vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;
$db = new FirestoreClient();
$docRef = $db->collection('clients')->document('10001');
$snapshot = $docRef->snapshot();

完整错误消息: 致命错误:未捕获的Google \ Cloud \ Core \ Exception \ FailedPreconditionException:{“ message”:“未为项目xxxxx启用Cloud Firestore API”,“ code”:9,“ status”:“ FAILED_PRECONDITION”,“详细信息” :[]}在C:\ vendor \ google \ cloud-core \ src \ GrpcRequestWrapper.php:263中堆栈跟踪:#0 C:\ vendor \ google \ cloud-core \ src \ GrpcRequestWrapper.php(200):Google \ Cloud \ Core \ GrpcRequestWrapper-> convertToGoogleException(Object(Google \ ApiCore \ ApiException))#1 [内部函数]:Google \ Cloud \ Core \ GrpcRequestWrapper-> handleStream(Object(Google \ ApiCore \ ServerStream))#2 C:\ vendor \ google \ cloud-firestore \ src \ SnapshotTrait.php(122):Generator-> current()#3 C:\ vendor \ google \ cloud-firestore \ src \ SnapshotTrait.php(61):Google \ Cloud \ Firestore \ DocumentReference-> getSnapshot(Object(Google \ Cloud \ Firestore \ Connection \ Grpc),'projects / cityda ...',Array)#4 C:\ vendor \ google \ cloud-firestore \ src \ DocumentReference.php(347 ):Google \ Cloud \ Firestore \ DocumentReference-> createSnapshot(Object(Google \ Cloud \ Fires in C:\ vendor \ google \ cloud-core \ src \ GrpcRequestWrapper.php,第263行

0 个答案:

没有答案