0
我在嘗試構建一個CMS,它使用Google Drive帳戶作爲存儲並顯示其內容,文件/文件夾,用戶應能夠通過我的管理文件Angular FrontEnd。我對google-api很陌生,認爲我試了一下,但我被卡住了。PHP google-api-php-client獲取用戶文件結構
我正在使用此庫在本地xampp中使用PHP來工作。
我試圖讓在用戶文件以.php測試文件這樣的迴應:
/*************************************************
* Ensure you've downloaded your oauth credentials
************************************************/
if (!$oauth_credentials = getOAuthCredentialsFile())
{
echo missingOAuth2CredentialsWarning();
return;
}
/************************************************
* The redirect URI is to the current page, e.g:
* http://localhost:8080/simple-file-upload.php
************************************************/
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$client = new Google_Client();
$client->setAuthConfig($oauth_credentials);
$client->setRedirectUri($redirect_uri);
$client->addScope(Google_Service_Drive::DRIVE);
$service = new Google_Service_Drive($client);
$pageToken = null;
do {
$response = $service->files->listFiles();
foreach ($response->files as $file) {
printf("Found file: %s (%s)\n", $file->name, $file->id);
}
} while ($pageToken != null);
但是,這將引發致命錯誤:未捕獲Google_Service_Exception:{ 「錯誤」:{ 「錯誤」:[{「domain」:「usageLimits」,「reason」:「dailyLimitExceededUnreg」,「message」:「每日限制未經驗證的使用超過。繼續使用需要註冊。」,
我得到git倉庫工作。但我沒有找到一個有用的例子來查詢用戶文件結構。
我以前有這個錯誤,我當我發送的請求未通過身份驗證時發生。 – Morfinismo
該庫中有多個身份驗證(OAuth,服務帳戶),此類請求需要什麼,或者它甚至很重要?當我嘗試上傳示例時,系統會要求我登錄併成功將文件上傳到驅動器。如果我將身份驗證部分複製到此查詢文件,它不起作用。 – AHahn