【发布时间】:2020-03-16 23:51:46
【问题描述】:
- 我已经用 composer(终端)安装了谷歌云文件
- export GOOGLE_APPLICATION_CREDENTIALS='...'
- 从 gcloud 收到我的 .json 密钥,该密钥与我的代码位于同一目录中
- 在我的 google 数据存储中创建了 3 个实体
我正在尝试做的所有事情:
<?php
session_start();
require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\Datastore\DatastoreClient;
putenv('GOOGLE_APPLICATION_CREDENTIALS=...');
// Various checks
if(isset($_POST["userId"]) && isset($_POST["password"])){
$userId = $_POST["userId"];
$password = $_POST["password"];
$datastore = new DatastoreClient(["..." => $projectId]);
$key = $datastore->key($userId, $password);
$entity = $datastore->lookup($key);
if($entity != null){
// do stuff...
}
?>
页面加载正常,只是当我提交表单时它崩溃了,给出了异常/错误,说明它找不到 .json 文件或无法验证我的凭据。
[更新]: 通过放置 putenv() 似乎可以创建数据存储对象,但每当我尝试使用 lookup() 函数检索实体时,我都会收到以下错误代码:
Fatal error: Uncaught exception 'Google\Cloud\Core\Exception\ServiceException' with message
"No system CA bundle could be found in any of the the common system
locations. PHP versions earlier than 5.6 are not properly configured
to use the system's CA bundle by default. In order to verify peer
certificates, you will need to supply the path on disk to a
certificate bundle to the 'verify' request option:
http://docs.guzzlephp.org/en/latest/clients.html#verify.
If you do not need a specific certificate bundle, then Mozilla provides a commonly used CA bundle which can be downloaded here (provided by the maintainer of cURL):
https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt.
Once you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP ini setting to point to the path to the file, allowing you to omit the 'verify' request option.
See http://curl.haxx.se/docs/sslcerts.html for more information."
我非常不熟悉 CA 捆绑包是什么,或者我想如何使用它来解决这里的问题。
【问题讨论】:
-
您好,您能否包括您收到的错误信息?