我从文档here中读到了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"
}
任何人都知道如何使用这种方法?感谢
答案 0 :(得分:1)
该方法是Content ID API的一部分,仅限高级合作伙伴。有关合作伙伴的更多信息:https://www.youtube.com/yt/creators/creator-benefits.html 然后,您可以向您的代表询问API。