Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导出在Google Drive API REST 3和PHP中不起作用_Php_Rest_Google Drive Api_Export - Fatal编程技术网

导出在Google Drive API REST 3和PHP中不起作用

导出在Google Drive API REST 3和PHP中不起作用,php,rest,google-drive-api,export,Php,Rest,Google Drive Api,Export,我正在尝试使用以下API将excel文件从Google Drive导出到scv文件: 我正在使用google-api-php-client-2.1.0 我的代码是: $content = $service->files->export($fileId, 'text/csv', array('alt' => 'media'); 但我不接收内容,只接收http\Psr7\Response 全部答复: GuzzleHttp\Psr7\Response::__set_state(

我正在尝试使用以下API将excel文件从Google Drive导出到scv文件:

我正在使用google-api-php-client-2.1.0

我的代码是:

$content = $service->files->export($fileId, 'text/csv', array('alt' => 'media');
但我不接收内容,只接收http\Psr7\Response

全部答复:

GuzzleHttp\Psr7\Response::__set_state(array(
'reasonPhrase' => 'OK',
'statusCode' => 200,
'headers' =>
array (
'expires' =>
array (
0 => 'Fri, 30 Dec 2016 11:18:35 GMT',
),
'date' =>
array (
0 => 'Fri, 30 Dec 2016 11:18:35 GMT',
),
'cache-control' =>
array (
0 => 'private, max-age=0, must-revalidate, no-transform',
),
'content-disposition' =>
array (
0 => 'attachment',
),
'vary' =>
array (
0 => 'Origin',
1 => 'X-Origin',
),
'content-type' =>
array (
0 => 'text/csv',
),
'x-content-type-options' =>
array (
0 => 'nosniff',
),
'x-frame-options' =>
array (
0 => 'SAMEORIGIN',
),
'x-xss-protection' =>
array (
0 => '1; mode=block',
),
'content-length' =>
array (
0 => '0',
),
'server' =>
array (
0 => 'GSE',
),
'alt-svc' =>
array (
0 => 'quic=":443"; ma=2592000; v="35,34"',
),
),
'headerLines' =>
array (
'Expires' =>
array (
0 => 'Fri, 30 Dec 2016 11:18:35 GMT',
),
'Date' =>
array (
0 => 'Fri, 30 Dec 2016 11:18:35 GMT',
),
'Cache-Control' =>
array (
0 => 'private, max-age=0, must-revalidate, no-transform',
),
'Content-Disposition' =>
array (
0 => 'attachment',
),
'Vary' =>
array (
0 => 'Origin',
1 => 'X-Origin',
),
'Content-Type' =>
array (
0 => 'text/csv',
),
'X-Content-Type-Options' =>
array (
0 => 'nosniff',
),
'X-Frame-Options' =>
array (
0 => 'SAMEORIGIN',
),
'X-XSS-Protection' =>
array (
0 => '1; mode=block',
),
'Content-Length' =>
array (
0 => '0',
),
'Server' =>
array (
0 => 'GSE',
),
'Alt-Svc' =>
array (
0 => 'quic=":443"; ma=2592000; v="35,34"',
),
),
'protocol' => '1.1',
'stream' =>
GuzzleHttp\Psr7\Stream::__set_state(array(
'stream' => NULL,
'size' => NULL,
'seekable' => true,
'readable' => true,
'writable' => true,
'uri' => 'php://temp',
'customMetadata' =>
array (
),
)),
))
我怎样才能得到文件的内容?

找到了答案

要从a GuzzleHttp\Psr7\响应读取导出文件的内容,我们应该使用:

$file = $service->files->export($fileId, 'text/csv', array(
        'alt' => 'media' ));
    $size = $file->getBody()->getSize();
    if($size > 0) {
        $content = $file->getBody()->read($size);
    }

出口不起作用是什么意思?你在本地主机上试过了吗?或者在服务器中搜索已导出的文件?原始响应日志看起来像来自
print\u r()
var\u dump()
,因此可能是缩进的。请再次粘贴,以便在问题中添加缩进,而不是粘贴在粘贴板上。