如何使用Google.Apis.YouTubeAnalytics.v2或Google.Apis.YouTubeReporting.v1下载YouTube指标

时间:2019-02-02 18:37:12

标签: c# .net youtube-analytics-api youtube-analytics

我需要使用C#控制台程序下载“ youtube Analytics”数据,以下是用于下载数据的代码。这里的 “Reports.Query()。执行()” 被抛出异常。

Errors [
    Message[Required] Location[ - ] Reason[required] Domain[global]
]

在以下

有人可以请帮助

私有静态无效GetYoutubeAnalytics()         {

        string[] scopes = { YouTubeReportingService.Scope.YtAnalyticsReadonly, YouTubeReportingService.Scope.YtAnalyticsMonetaryReadonly }; //Read-only access to Google Analytics
        GoogleCredential credential;
        using (FileStream stream = new FileStream("YoutubeAnalytics-ac2d31ec7846.json", FileMode.Open, FileAccess.Read))
        {
            credential = GoogleCredential.FromStream(stream).CreateScoped(scopes);
        }

        YouTubeAnalyticsService _service = new YouTubeAnalyticsService(new BaseClientService.Initializer()
        {
            ApplicationName="KI Youtube Extractor",
            HttpClientInitializer=credential                
        });

        Google.Apis.YouTubeAnalytics.v2.Data.QueryResponse r = _service.Reports.Query().Execute();
    }

0 个答案:

没有答案