0

Google Drive API と Drive SDK を使用して最初のアプリを作成しようとしています。Googleドライブからファイルを開こうとしています。これが私のコードです:

if(isset($_GET['state'])){
    $json = $_GET['state'];
    $obj = json_decode($json);
    $idTab = $obj->{'ids'};
    $id = $idTab[0];
    $file = printFile($service, $id);
}
    function printFile($service, $fileId) {
    try {
        $file = $service->files->get($fileId);
        return $file;
    } catch (Exception $e) {
        print 'Error: '.$e->getMessage();
        return null;
      }
}

function downloadFile($file) {

    $downloadUrl = $file->getDownloadUrl();
      if ($downloadUrl) {
        $request = new Google_HttpRequest($downloadUrl, 'GET', null, null);
        $httpRequest = Google_Client::$io->authenticatedRequest($request);
        if ($httpRequest->getResponseHttpCode() == 200) {
            return $httpRequest->getResponseBody();
          } else {
          // An error occurred.
          return null;
        }
    } else {
    // The file doesn't have any content stored on Drive.
    return null;
  }
    }

Api コンソールで Google Drive API と Drive SDK を有効にしました。クライアント ID、電子メール アドレス、Web アプリケーションのクライアント シークレット、および API キーと許可されたリファラー (HTTP からの受け入れられた要求) を設定しました。クライアント ID、開く URL など、必要なすべてのデータを Google ドライブ SDK に入力しました。私の追加スコープは次のとおりです: [https://www.googleapis.com/auth/userinfo.profile]、[https://www.googleapis.com/auth/drive.install]、[https://www.googleapis. com/auth/drive.file]、[https://www.googleapis.com/auth/drive]。

アプリケーションを Google ストアにインストールし、アプリケーションでドライブからファイルを開こうとしています。次のエラーがあります:

{
 "error": {
  "errors": [
  {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured"
   }
  ],
  "code": 403,
"message": "Access Not Configured"
 }
} 

解決策を探していますが、見つかりません。何も役に立ちません。この問題を解決するために誰か助けてください。

4

1 に答える 1

0

Drive SDK と Drive API サービスをオンにしましたが、まだエラーが発生します。You show me の投稿では、解決策は Drive SDK と Drive API サービスをオンにすることでした。私の場合、それは解決策ではありません。

于 2013-09-23T08:25:37.073 に答える