我有一个独立的PHP程序(不是Web服务器的一部分),需要访问Google表格,并且不断收到臭名昭著的curl错误6。我尝试将证书路径添加到PHP.INI文件,我尝试在客户端配置中将其关闭,但没有任何效果。任何人都可以提出其他可能解决问题的建议吗?
class GoogleFunctions
{
private $client;
private $accessToken;
private $sheetsService;
private $driveService;
/*
* Establish our connection with Google and create Drive and Sheet clients
* */
public function initialize() {
/*
* We need to get a Google_Client object first to handle auth and api calls, etc.
*/
//$http = new GuzzleHttp\Client(['verify' => './Certificates/cacert.pem']);
//$http = new GuzzleHttp\Client(['verify' => 'C:\Development\EDPS\EDPS\Development\.credentials\cacert.pem']);
$http = new GuzzleHttp\Client(['verify' => false]);
$this->client = new Google_Client();
$this->client->setHttpClient($http);
$this->client->setApplicationName('EDPS');
$this->client->setScopes(Google_Service_Drive::DRIVE_FILE or Google_Service_Sheets::SPREADSHEETS);
$this->client->setAuthConfig('sheets_api_secret.json');
$this->client->setAccessType('offline');
$this->refreshAccessToken();
$accessToken = $this->client->fetchAccessTokenWithAssertion()["access_token"];
/* ServiceRequestFactory::setInstance(new DefaultServiceRequest($accessToken)); */
$this->client->setAccessToken($accessToken);
/*
* Get our two services for accessing folders and sheets.
*/
$this->sheetsService = new \Google_Service_Sheets($this->client);
$this->driveService = new Google_Service_Drive($this->client);
}
。 。
private function refreshAccessToken() {
if ($this->client->isAccessTokenExpired()) {
$this->client->refreshTokenWithAssertion();
}
}
}
代码始终在上述函数refreshTokenWithAssertion中死于卷曲错误60。我关注了几篇文章,这些文章建议提供您自己的Guzzle客户端(如上所示),但似乎无济于事。真正令人生气的是,该代码在一台Windows PC上可以正常工作,但是当转移到开发笔记本电脑以与客户端一起使用时,它就停止了工作。我正在使用Google 2 api客户端运行PHP 5.6.36。还有其他建议吗?