gpt4 book ai didi

php - SSL 错误 Google Drive API

转载 作者:太空宇宙 更新时间:2023-11-03 15:13:12 26 4
gpt4 key购买 nike

我正在使用 PHP 库检索文件或将它们上传到 Google 驱动器

include_once ROOT.'/google-api-php-client/vendor/autoload.php';

$client = new Google_Client();

$credentialsFile = ROOT.'/google-api-php-client/service_account.json';
if (!file_exists($credentialsFile)) {
throw new RuntimeException('Service account credentials Not Found!');
}

$client->setAuthConfig($credentialsFile);
$client->setScopes(Google_Service_Drive::DRIVE);

$service = new Google_Service_Drive($client);

/**
* Проверка существования папки для документов
*/

$optParams = array(
'q' => "name='Документы'"
);
$results = $service->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
exit('Нет папки для документов');
} else {
foreach ($results->getFiles() as $file) {
$papka_doc = $file->getId();
}
}

一切正常,但几天前,出现错误:

Uncaught exception 'GuzzleHttp\\Exception\\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

可能是什么问题?

最佳答案

试试这个,

首先,你应该下载curl.cert文件,

curl https://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt

其次,设置这个证书。

$client->getHttpClient()->setDefaultOption('verify', '[Certificate File Path]');

Centos默认路径;

/etc/pki/tls/certs/ca-bundle.crt

关于php - SSL 错误 Google Drive API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47051145/

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