微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Google Drive API 的 Wordpress 网站出现致命的 GuzzleHTTP cURL 错误 7

如何解决使用 Google Drive API 的 Wordpress 网站出现致命的 GuzzleHTTP cURL 错误 7

我在我的 wordpress 网站上遇到了一个困难的错误。我正在使用 Google Drive API。有时在我的 wordpress 网站上,我会收到这个 500 服务器异常。异常时而出现,时而消失。我们已尝试创建新的服务帐户,但错误仍然存​​在。

这是个例外:

致命错误:未捕获的 GuzzleHttp\Exception\ConnectException: cURL 错误 7:(见 https://curl.haxx.se/libcurl/c/libcurl-errors.html)在 /home/www/testing.com/wp-content/themes/testingspace/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.PHP:200 堆栈跟踪:#0 /home/www/testing.com/wp-content/themes/testingspace/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.PHP(155): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle),数组)#1 /home/www/testing.com/wp-content/themes/testingspace/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.PHP(105): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler),对象(GuzzleHttp\Handler\EasyHandle), 对象(GuzzleHttp\Handler\CurlFactory))#2 /home/www/testing.com/wp-content/themes/testingspace/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.PHP(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler),对象(GuzzleHttp\Handler\EasyHandle), 对象(GuzzleHttp\Handler\CurlFactory))#3 /home/www/testing.com/wp-content/ 在 /home/www/testing.com/wp-content/themes/testingspace/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.PHP 在线 200

即使它消失了,我仍然无法访问 Google Drive 帐户。下面是我的测试代码片段。我列出了相关函数 (getClient,getToolDrive,getDocuments) 和用于调用这些函数代码代码的连接/身份验证部分是对 google’s quickstart php code for setting up Google Drive API 的直接复制和粘贴,因此应该不是问题。

function getClient() {
    $client = new Google_Client();
    $client->setAuthConfig(__DIR__ . "/ tool-dev1283726.json");
    $client->setApplicationName(“Testing”);
    $client->setScopes(Google_Service_Drive::DRIVE);

    return $client;
}

function getToolDrive($service,$user)
{
    // Print the names and IDs for up to 30 files.
    $optParams = array(
    'pageSize' => 30,'fields' => 'nextPagetoken,files(id,name)'
    );
    
    try {
        $results = $service->files->listFiles($optParams); //exception is thrown here
    } catch (Exception $e) {
        
        console_log('Caught exception: ' .  $e->getMessage()); // the exception thrown is the curl 7 error I shown above
    } finally {
        
        console_log($service->files);
    }
   
    $userFolder = null; //I just set this to null because I was only interested in testing out why $service->files->listFiles was not working
    return $userFolder;
}
function getDocuments($service,$user) {
    $userFolderId = getToolDrive($service,$user);
    return null; //I return null because everything below $userFolderId is not called cause the exception is thrown in getPaperToolDrive
}

$client = getClient();
$service = new Google_Service_Drive($client);
// echo response text
// If a POST request to self was made,hide all output except the material update.
if(count($_POST) > 0) {
    ob_end_clean();
}
$documents = getDocuments($service,$current_user->user_login);

那么我们如何修复这个异常呢?我们是否可能需要更新某些内容(例如 Guzzle)?任何帮助是极大的赞赏!谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。