如何启用/禁用YouTube api上传的视频货币化



我从文档中读到这里有一个方法setMonetizationDetails(VideoMonetizationDetails monetizationDetails),所以这是我的代码

Video videoObjectDefiningMetadata = new Video();
// Set the video to be publicly visible. This is the default
// setting. Other supporting settings are "unlisted" and "private."
VideoStatus status = new VideoStatus();
status.setPrivacyStatus("public");
videoObjectDefiningMetadata.setStatus(status);
//set accesspolicy: allow monetize or not
AccessPolicy accessPolicy = new AccessPolicy();
accessPolicy.setAllowed(false);
VideoMonetizationDetails videoMonetizationDetail = new VideoMonetizationDetails();
videoMonetizationDetail.setAccess(accessPolicy);
videoObjectDefiningMetadata.setMonetizationDetails(videoMonetizationDetail);
/*set snippet*/
YouTube.Videos.Insert videoInsert = youtube.videos()
            .insert("monetizationDetails,snippet,statistics,status,contentDetails", videoObjectDefiningMetadata, mediaContent);

给出错误

GoogleJsonResponseException code: 403 : Forbidden
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "youtube.common",
    "message" : "Forbidden",
    "reason" : "forbidden"
  } ],
  "message" : "Forbidden"
}

有人知道怎么用这个方法吗?由于

该方法是Content ID API的一部分,仅限于高级合作伙伴。更多合作信息:https://www.youtube.com/yt/creators/creator-benefits.html然后你可以向你的代表询问API。

相关内容

  • 没有找到相关文章

最新更新