Google 我的企业 PHP Api OpenSSL SSL_connect: SSL_ERROR_SYSCALL
Google MyBusiness PHP Api OpenSSL SSL_connect: SSL_ERROR_SYSCALL
我的部分代码是:
try {
$client = new Google_Client();
$client->setAuthConfig($credentials_file);
$client->setAccessType("offline");
$client->setIncludeGrantedScopes(true);
$client->addScope("https://www.googleapis.com/auth/plus.business.manage");
}catch(GuzzleHttp\Exception\ConnectException $e){
Connector::handleException($e); //just print $e->getMessage(); and die();
}catch(\Exception $e){
Connector::handleException($e); //just print $e->getMessage(); and die();
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
$connector = Connector::init($client);
require_once "views/index.php";
} else {
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/oauth2callback.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
在 views/index.php
中,我只是获取位置并打印出来。
我运行我的'app'和php -S localhost:8000
几乎一切正常,因为我有时会遇到错误:
cURL error 35: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to mybusiness.googleapis.com:443 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
和
cURL error 35: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to oauth2.googleapis.com:443 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
我需要刷新站点几次,直到一切恢复正常。几天前一切都很好。有时会在第一次刷新后开始工作,有时需要 5 分钟。
为什么?我能以某种方式修复它吗?
似乎 Google API 对 IPv6 的 curl 有问题,所以在文件中:
vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php
关于第 40 行我添加了:
curl_setopt($easy->handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
它解决了问题!
我的部分代码是:
try {
$client = new Google_Client();
$client->setAuthConfig($credentials_file);
$client->setAccessType("offline");
$client->setIncludeGrantedScopes(true);
$client->addScope("https://www.googleapis.com/auth/plus.business.manage");
}catch(GuzzleHttp\Exception\ConnectException $e){
Connector::handleException($e); //just print $e->getMessage(); and die();
}catch(\Exception $e){
Connector::handleException($e); //just print $e->getMessage(); and die();
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
$connector = Connector::init($client);
require_once "views/index.php";
} else {
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/oauth2callback.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
在 views/index.php
中,我只是获取位置并打印出来。
我运行我的'app'和php -S localhost:8000
几乎一切正常,因为我有时会遇到错误:
cURL error 35: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to mybusiness.googleapis.com:443 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
和
cURL error 35: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to oauth2.googleapis.com:443 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
我需要刷新站点几次,直到一切恢复正常。几天前一切都很好。有时会在第一次刷新后开始工作,有时需要 5 分钟。
为什么?我能以某种方式修复它吗?
似乎 Google API 对 IPv6 的 curl 有问题,所以在文件中:
vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php
关于第 40 行我添加了:
curl_setopt($easy->handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
它解决了问题!