URL error 0: The cURL request was retried 3 times

2019-02-26 00:42发布

I am working on a project that is hosted on Google App Engine, and using app_devserver for local development. At the start I had problems with certificates but when I finally got over that error I am getting this new error

I am using Windows 10 and PHPstorm for development.

Error:

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)

Looks like this error is saying that the request is made and successfull but the body could not be resolved or parsed? How can I resolve it?

This is my PHP code if needed: (simple call to tag manager 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).')';

1条回答
叼着烟拽天下
2楼-- · 2019-02-26 00:46

I had exactly this problem using the Google Drive app, after hours trying to find a solution, I got it to work using the GuzzleHttp sink option

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

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

Worth the try.

查看更多
登录 后发表回答