cURL 错误 60:SSL 证书 prblm:无法获取本地颁发者证书

2022-01-19 00:00:00 youtube-api youtube-data-api wamp php

我想使用 YouTube 数据 API 收集上传到特定频道的视频列表.但是,在在线实施之前,我试图让我的代码在离线环境(WAMPserver、PHP 5.5.12、Apache 2.4.9)上运行.我正在使用以下代码:

I want to collect a list of videos uploaded on a specific channel using the YouTube data API. However, before implementing online I am trying to get my code running on an offline environment (WAMPserver, PHP 5.5.12, Apache 2.4.9). I am using the following code:

require_once 'google-api-php-client-2.0.0-RC5/vendor/autoload.php';

$client = new Google_Client();
$client->setApplicationName("SRC_Thor");
$client->setDeveloperKey("xxxxxxxxxxx");

$youtube = new Google_Service_YouTube($client);

$channelResponse = $youtube->channels->listChannels('contentDetails', []);
var_dump($channelResponse);

但是它给出了以下错误:

However it gives the following error:

致命错误:未捕获异常 'GuzzleHttpExceptionRequestException' 并带有消息 'cURL 错误 60:SSL 证书问题:无法获取本地颁发者证书(请参阅 http://curl.haxx.se/libcurl/c/libcurl-errors.html)'

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

我已尝试添加最新版本的 cacert.pem 作为 SO 上的大多数主题提供的解决方案,但无济于事.

I have tried adding the latest version of cacert.pem as most topics on SO offer as a solution, however to no avail.

推荐答案

如果你在 Windows 上使用 Xampp,我从 窃取了一个更好的答案此处,如果 Google 先向您显示此问题会很有帮助.

If you are on Windows using Xampp, I am stealing a better answer from here, would be helpful if Google shows you this question first.

  1. 在此处下载并提取 cacert.pem(干净的文件格式/数据)

  1. Download and extract for cacert.pem here (a clean file format/data)

https://curl.haxx.se/docs/caextract.html

  • 放入:

  • Put it in :

    C:xamppphpextrassslcacert.pem

    C:xamppphpextrassslcacert.pem

  • 将此行添加到您的 php.ini

  • Add this line to your php.ini

    curl.cainfo = "C:xamppphpextrassslcacert.pem"

    curl.cainfo = "C:xamppphpextrassslcacert.pem"

  • 重启你的网络服务器/Apache

  • restart your webserver/Apache

  • 相关文章