php - 网址错误 0 : The cURL request was retried 3 times and did not succeed

标签 php google-app-engine curl ssl-certificate php-curl

我正在开展一个托管在 Google App Engine 上的项目,并使用 app_devserver 进行本地开发。一开始我遇到了证书问题,但是当我终于克服了这个错误时,我得到了这个新错误

我正在使用 Windows 10 和 PHPstorm 进行开发。

错误:

Message: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

看起来这个错误是说请求已成功发出但正文无法解析或解析?我该如何解决?

如果需要,这是我的 PHP 代码:(简单调用标签管理器 api v2)

    $client = new Google_Client();
    $client->setAuthConfig('service_account.json');

    $client->setApplicationName("gtmdocx");
    /*$client->setScopes(['https://www.googleapis.com/auth/tagmanager.readonly',
                        'https://www.googleapis.com/auth/tagmanager.manage.accounts',
                        'https://www.googleapis.com/auth/tagmanager.edit.containers']);*/
    $client->setScopes(['https://www.googleapis.com/auth/tagmanager.readonly']);
    $service = new Google_Service_TagManager($client);
    $results = $service->accounts->listAccounts();


    echo $_GET['callback'] . '('.json_encode($results).')';

最佳答案

我在使用 Google 云端硬盘应用程序时遇到了这个问题,在尝试找到解决方案几个小时后,我使用 GuzzleHttp 接收器选项让它工作

$client = new \Google_Client();
// ... Client Configuration

$httpClient = new Client([
    'sink' => 'path_to_any_temp_file',
    'base_uri' => $client->getConfig('base_path'),
]);
$client->setHttpClient($httpClient);

值得一试。

关于php - 网址错误 0 : The cURL request was retried 3 times and did not succeed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46323867/

相关文章:

php - 使用 PHP 从 doc、xls 文件中读取数据

php - 如何将具有一对多关系的数据从 MySQL 处理到 PHP

c - 使用 gtk 的多线程进度条控制

php - Apache/PHP 和 Systemd/node 可读的环境变量

php - Laravel HasManyThrough 与 3 向数据透视表

google-app-engine - 在 webapp2.RequestHandler 的 post 方法中执行 if self.request.POST "not indexable"时得到 TypeError, ['file'

python - 异常 : Server returned HTTP code: 404 --- testing app with Google App Engine and Google Earth Engine

python - 对 GAE 中根实体的强一致性查询?

php - OpenAI API 错误 : "You didn' t provide an API key. 您需要使用 Bearer auth 在授权 header 中提供您的 API key ”

bash - 在 bash 中解析和存储 curl 命令的 json 输出