Google_Http_REST :: decodeHttpResponse意外抛出异常

时间:2014-04-24 03:49:18

标签: google-drive-api

我们正在使用PHP客户端:“google / apiclient”:“1.0.4-beta”将CSV上传到我们的google云端硬盘。我们的剧本以前工作过,但现在停止工作。我们没有改变任何事情。我们尝试了开发,升级,生产Google产品ID,都抛出相同的错误。 API方面有什么问题吗?或者我们的剧本有问题吗?

例外:

#0 /home/dev/workspace/fb/vendor/google/apiclient/src/Google/Http/REST.php(44): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request))
#1 /home/dev/workspace/fb/vendor/google/apiclient/src/Google/Client.php(499): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#2 /home/dev/workspace/fb/vendor/google/apiclient/src/Google/Service/Resource.php(195): Google_Client->execute(Object(Google_Http_Request))
#3 /home/dev/workspace/fb/vendor/google/apiclient/src/Google/Service/Drive.php(1694): Google_Service_Resource->call('insert', Array, 'Google_Service_...')
#4 /home/dev/workspace/fb/app/modules/Core/Models/Report/Generator/Spreadsheet/Google.php(53): Google_Service_Drive_Files_Resource->insert(Object(Google_Service_Drive_DriveFile), Array)
#5 /home/dev/workspace/fb/app/modules/Core/Models/Report/Manager.php(69): Core\Models\Report\Generator\Spreadsheet\Google->insert('report_21_test_...', Array)
#6 /home/dev/workspace/fb/app/modules/Core/Commands/Report/GenerateByQuery.php(55): 
......

我们的守则:         $ client = new \ Google_Client();

    $client->setClientId($apiConfig['clientId']);
    $client->setAssertionCredentials(new \Google_Auth_AssertionCredentials(
        $apiConfig['accountName'],
        array('https://www.googleapis.com/auth/drive'),
        $key
    ));

    $this->service = new \Google_Service_Drive($client);


    $date = date("Y-m-d H:i:s");

    // slice to max rows
    $data = array_slice($data, 0, self::MAX_ROWS);

    // generate spreadsheet with filename and data
    $file = new \Google_Service_Drive_DriveFile();
    $file->setTitle("$filename");
    $file->setDescription("Report generate at $date");
    $file->setMimeType(self::MIME_TYPE_ORIGINAL);

    $csvStr = $this->getCsvString($data);

    $createdFile = $this->service->files->insert($file, array(
        'data'       => $csvStr,
        'mimeType'   => self::MIME_TYPE_GOOGLE,
        'uploadType' => 'multipart',
        'convert'    => true,
    )); // exception is from here

    // set permission
    $this->service->permissions->insert($createdFile->getId(), $this->getPermission());

1 个答案:

答案 0 :(得分:0)

这是一个暂时的问题,现在已修复。