如何禁止使用YouTube API asp.net评论和评级禁止使用、YouTube、API、asp

2023-09-06 23:38:51 作者:魅如樱花的她。

任何帮助将是非常美联社preciated!

目前的code:

  YouTubeRequest请求=连接();
视频视频=新视频();

video.Tags.Add(新MediaCategory(非营利,YouTubeNameTable.CategorySchema));
video.Keywords =测试;
video.YouTubeEntry.setYouTubeExtension(位置,英国);
 

解决方案

下面的方法需要在YouTube视频从YouTube的请求服务检索并也需要在许可的类型和新的权限。

 私人视频SetAccessControl(视频录像,字符串类型,字符串许可)
    {
        VAR EXTS = video.YouTubeEntry
            .ExtensionElements
            。凡(X => x是XmlExtension)
            。选择(X => x作为XmlExtension)
            。凡(X => x.Node.Attributes [行动] = NULL和放大器;!&安培; x.Node.Attributes [行动]的InnerText ==型);

        VAR EXT = exts.FirstOrDefault();

        如果(EXT!= NULL)
            。ext.Node.Attributes [权限]的InnerText =许可;

        返回视频;
    }
 

注的这个只能在一个检索到的视频,而不是如果你传递一个的新视频()的

它的作用是,遍历所有你管返回作为饲料的一部分ExtentionElements,并提取XML扩展元素(因为没有一个建立在C#中的访问控制扩展)需要匹配,其中的元素动作类型==然后更新权限归因于所需的值。

使用安卓Youtube API播放youtube视频

当视频条目被发送和更新,以YouTube的服务器更新的访问控制元件被发回,并与更新请求。

Any help would be much appreciated!

Current code:

YouTubeRequest request = Connect();
Video video = new Video();

video.Tags.Add(new MediaCategory("Nonprofit", YouTubeNameTable.CategorySchema));
video.Keywords = "Test";
video.YouTubeEntry.setYouTubeExtension("location", "UK");

解决方案

The below method takes in a YouTube video retrieved from the YouTube request service and also takes in the type of permission and the new permissions.

 private Video SetAccessControl(Video video, string type, string permission)
    {
        var exts = video.YouTubeEntry
            .ExtensionElements
            .Where(x => x is XmlExtension)
            .Select(x => x as XmlExtension)
            .Where(x => x.Node.Attributes["action"] != null && x.Node.Attributes["action"].InnerText == type);

        var ext = exts.FirstOrDefault();

        if (ext != null)
            ext.Node.Attributes["permission"].InnerText = permission;

        return video;
    }

NOTE this will only work on a retrieved video, not if you pass in a "new Video()"

what it does is, iterates over all the ExtentionElements that you tube returned as part of the feed, and extracts the xml extension elements (as there isn't a build in c# access control extension) takes the elements that match where the action == type then updates the permissions attribute to the required value.

When the video entry is sent and updated to the YouTube server the updated access control elements are sent back and with the update request.

 
精彩推荐