![](/img/trans.png)
[英]Problem Getting Verification Code in Google Drive API Using PHP
[英]Getting an image using the Google Drive PHP API
我正在嘗試使用 PHP API 檢索位於 Google Drive 中的圖像。 授權有效,但我似乎無法弄清楚如何讓圖像文件將其放置在文件夾中。 我在網上沒有找到任何結果。
目前使用
$driveService->files->get($fileId)
,
其中 $driveService 是 Google_Service_Drive class。
然后我嘗試使用 webContentLink 來下載文件,但 webContentLink 被設置為 null。 該圖像位於一個文件夾中,該文件夾具有授予服務帳戶的編輯權限,該服務帳戶用於訪問圖像。
webContentLink 僅適用於二進制文件。 如果您使用的是 file.get,您只需編寫獲取正文並將其寫入文件。
$file = $service->files->get($fileId, array('alt' => 'media'));
file_put_contents("hello.pdf",$file->getBody());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.