【问题标题】:Disable video comments through the youtube API in Java通过 Java 中的 youtube API 禁用视频评论
【发布时间】:2012-01-20 00:13:22
【问题描述】:

使用 Youtube API 上传视频时如何在 java 中禁用 cmets?

【问题讨论】:

    标签: youtube youtube-api


    【解决方案1】:

    快速谷歌后,我找到了this

    您要做的是向视频条目添加一个 yt:accessControl 元素,其操作属性为“comment”,权限属性为“moderated”。我不相信 Java 客户端库中有本机支持或 yt:accessControl 元素,因此必须“手动”完成。这是一些示例代码 假设您刚刚创建了一个新视频,然后执行部分更新以设置该视频的 yt:accessControl 值:

    VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);
    
    String atomXml = "<?xml version='1.0'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' gd:fields='yt:accessControl' xmlns:yt='http://gdata.youtube.com/schemas/2007'><yt:accessControl action='comment' permission='moderated'/></entry>";
    
    GDataRequest request = service.createPatchRequest(new URL(createdEntry.getEditLink().getHref()));
    request.getRequestStream().write(atomXml.getBytes("UTF-8"));
    request.execute();
    createdEntry = service.parseResponseData(request, VideoEntry.class);
    
    // createdEntry now contains the updated VideoEntry, and the access control should be set on it.
    

    【讨论】:

    • 请在答案中包含解决方案。
    • 对我来说“createdEntry.getEditLink()”变为空。知道为什么吗?
    猜你喜欢
    • 2012-11-07
    • 1970-01-01
    • 2013-11-21
    • 1970-01-01
    • 2017-10-04
    • 1970-01-01
    • 1970-01-01
    • 2010-12-13
    • 2016-09-01
    相关资源
    最近更新 更多