ばかげた質問で申し訳ありませんが、私はここに来たばかりで、フォローする方法がわかりません。
AndroidおよびIOのアプリをサポートするPHPのサーバーにGoogleドライブのサポートを実装しました。ファイルをGoogleドライブにアップロードしたり、問題なく削除したりできます。ファイルをダウンロードすると、次のようになりますhttpResponseCode は正しい 200 で、responseHeader も正しいですが、responseBody は空です。
誰かが何か考えがある場合に備えて、Google Drive Server からの応答をここに置きます。ありがとう
apiHttpRequest Object
(
[batchHeaders:apiHttpRequest:private] => Array
(
[Content-Type] => application/http
[Content-Transfer-Encoding] => binary
[MIME-Version] => 1.0
[Content-Length] =>
)
[url:protected] => https://doc-0s-6s-docs.googleusercontent.com/docs/securesc/3h10lch354ufu4pkrusuk27smk7k4ifq/qp3b555lfchhfmpfodjv4mcpbug1vol6/1346112000000/12488086635796486161/12488086635796486161/0B_cf3F02DuErM3V3b0o4WnYyNTA?h=16653014193614665626&e=download&gd=true
[requestMethod:protected] => GET
[requestHeaders:protected] => Array
(
[authorization] => Bearer ya29.AHES6ZQwIuu8ZhP8Uk389Sgo5NELnvArjzAC362ByzEsh2qa_gjDvJw
)
[postBody:protected] =>
[userAgent:protected] => google-api-php-client/0.5.0
[responseHttpCode:protected] => 200
[responseHeaders:protected] => Array
(
[server] => HTTP Upload Server Built on Aug 15 2012 18:03:01 (1345078981)
[access-control-allow-origin] => *
[access-control-allow-credentials] => false
[access-control-allow-headers] => authorization
[access-control-allow-methods] => GET,OPTIONS
[content-type] => video/quicktime
[content-disposition] => attachment;filename="VID_20120827_105737.mp4";filename*=UTF-8''VID_20120827_105737.mp4
[content-length] => 2768422
[date] => Tue, 28 Aug 2012 00:15:26 GMT
[expires] => Tue, 28 Aug 2012 00:15:26 GMT
[cache-control] => private, max-age=0
)
[responseBody:protected] =>
今私が使用しているコード:
public function GetFile($fileId) {
$fileVars = null;
try {
/*
* Retrieve metadata for the file specified by $fileId.
*/
$file = $this->service->files->get($fileId);
$fileVars = get_object_vars($file);
/*
* Retrieve the file's content using download URL specified in metadata.
*/
$downloadUrl = $file->getDownloadUrl();
error_log('Download URL file from Drive: ' . $downloadUrl);
if ($downloadUrl) {
$request = new apiHttpRequest($downloadUrl, 'GET', null, null);
$httpRequest = apiClient::$io->authenticatedRequest($request);
error_log(print_r($httpRequest, 1));
if ($httpRequest->getResponseHttpCode() == 200) {
$content = $httpRequest->getResponseBody();
$fileVars['content'] = $content?($content):'';
} else {
// An error occurred.
return null;
}
} else {
// The file doesn't have any content stored on Drive.
return null;
}
} catch (apiServiceException $e) {
/*
* Log error and re-throw
*/
error_log('Error retrieving file from Drive: ' . $e->getMessage());
throw $e;
}
return json_encode($fileVars);
}