【问题标题】:Youtube api get live broadcast ID with C#Youtube api用C#获取直播ID
【发布时间】:2017-05-10 19:06:40
【问题描述】:

我想尝试获取 youtube 直播 id。但我不能得到这个。 这是我的代码:

  UserCredential credential;
        Response.Write("AAA");
        var stream2 = new FileStream("c:/users/gislap/documents/visual studio 2012/Projects/youtube/secrect.json", FileMode.Open, FileAccess.Read);


            credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream2).Secrets,
                new[] { YouTubeService.Scope.Youtube },
                "user",
                CancellationToken.None,
                new FileDataStore(this.GetType().ToString())
            );
            Response.Write("DDD");

        var youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = this.GetType().ToString()
        });
        var my_video_request = youtubeService.LiveBroadcasts.ToString();

        Label1.Text = my_video_request.ToString();

或者有什么方法可以获取所有视频列表?

【问题讨论】:

    标签: c# youtube-api


    【解决方案1】:

    您可以参考这个thread。如果你想检索另一个频道当前直播的信息,你必须使用标准的Search/list端点:

    part -> snippet

    channelId -> [channelId of the channel/user with the live event]

    eventType -> live

    type -> video(将eventType设置为live时需要)

    HTTP GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channelId}&eventType=live&type=video&key={YOUR_API_KEY}
    

    此外,基于此documentation,尝试使用此 HTTP 请求返回与 API 请求参数匹配的 YouTube 广播列表。

    GET https://www.googleapis.com/youtube/v3/liveBroadcasts

    以下是可能有帮助的示例:

    【讨论】:

      猜你喜欢
      • 2015-07-05
      • 2016-09-28
      • 2022-11-07
      • 1970-01-01
      • 2015-08-01
      • 2017-07-31
      • 2015-10-18
      • 2018-03-12
      • 1970-01-01
      相关资源
      最近更新 更多