Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.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
C# 使用Google.api和c在我的Google站点上列出HTML文件#_C#_Google Api_Google Api Dotnet Client - Fatal编程技术网

C# 使用Google.api和c在我的Google站点上列出HTML文件#

C# 使用Google.api和c在我的Google站点上列出HTML文件#,c#,google-api,google-api-dotnet-client,C#,Google Api,Google Api Dotnet Client,我想用google.api列出我谷歌网站上的所有页面。使用Google.api.Drive.v3方法,我可以列出我的驱动器帐户的内容,但我的站点只有一个条目——标题的MimeType为“application/vnd.Google apps.site”。我正在使用一个服务帐户进行连接,它似乎正在工作。有没有其他方式与谷歌网站上的文件交互?这是我的密码: string[] scopes = { DriveService.Scope.Drive, DriveService.Scope.DriveFi

我想用google.api列出我谷歌网站上的所有页面。使用Google.api.Drive.v3方法,我可以列出我的驱动器帐户的内容,但我的站点只有一个条目——标题的MimeType为“application/vnd.Google apps.site”。我正在使用一个服务帐户进行连接,它似乎正在工作。有没有其他方式与谷歌网站上的文件交互?这是我的密码:

string[] scopes = { DriveService.Scope.Drive, DriveService.Scope.DriveFile, DriveService.Scope.DriveAppdata, DriveService.Scope.DriveMetadata, DriveService.Scope.DriveScripts };

        //open the service account private key file
        using (var stream = new FileStream("appName-bc2d6ad1c3bb.json", FileMode.Open, FileAccess.Read))
        {
            //create a new service credential
            var credential = GoogleCredential.FromStream(stream);
            credential = credential.CreateScoped(scopes);

            //create a new Drive service
            var service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "appName",
            });

            var files = service.Files.List().Execute().Files;
            foreach(var tmpFile in files)
            {
                //Only lists the site name, not the individual HTML files
                Console.WriteLine(tmpFile.Name + " : " + tmpFile.Id + " : " + tmpFile.MimeType);
            }

        }

首先,您需要记住,服务帐户不是您自己的。除非您授予服务帐户访问权限,否则它将无法访问数据。尝试访问您的站点并使用服务帐户电子邮件地址共享该站点


第二,你确定这些文件在谷歌硬盘上吗

如果我在我的账户下查看我的谷歌硬盘,我看到的只是一个网站条目,而不是单个文件。我甚至不知道如何通过谷歌驱动器页面查看单个文件。你怎么会认为这是可能的?谷歌为其所有其他服务提供了API,所以我认为这可能是可能的,并决定将其作为一种选择进行探索。如果这是不可能的,那么我将转向其他选项。我已经与谷歌API合作四年了。我非常擅长搜索那里的文档。我还没有发现任何证据表明这是可能的。我只是想知道你是不是在什么地方读到的。我唯一听说的是网站api,它只在旧网站上工作,而不是在新网站上。谢谢你提供的信息,我想我会走另一条路。