Javascript 未记录的函数-gapi.client.youtube.commentThreads.insert
Javascript 未记录的函数-gapi.client.youtube.commentThreads.insert,javascript,youtube-api,youtube-data-api,Javascript,Youtube Api,Youtube Data Api,当我浏览谷歌YouTube数据API时,发现了对象gapi.client.YouTube.commentThreads.insert,我试图使用它,但我不知道如何使用它,数据API文档也没有提供太多信息。 我试图像上面这样编写和运行代码,但它返回错误400 代码: 回应 { "error": { "errors": [ { "domain": "youtube.commentThread", "reason": "channelOrVideoIdMissing",
当我浏览谷歌YouTube数据API时,发现了对象gapi.client.YouTube.commentThreads.insert,我试图使用它,但我不知道如何使用它,数据API文档也没有提供太多信息。
我试图像上面这样编写和运行代码,但它返回错误400 代码: 回应
{
"error": {
"errors": [
{
"domain": "youtube.commentThread",
"reason": "channelOrVideoIdMissing",
"message": "Each comment thread must be linked to a channel or video.\u003cul\u003e\u003cli\u003eIf the comment applies to a channel, make sure that the resource specified in the request body provides a value for the \u003ccode\u003e\u003ca href=\"/youtube/v3/docs/commentThreads#snippet.channelId\"\u003esnippet.channelId\u003c/a\u003e\u003c/code\u003e property. A comment that applies to a channel appears on the channels \u003cb\u003eDiscussion\u003c/b\u003e tab.\u003c/li\u003e\u003cli\u003eIf the comment applies to a video, make sure the resource specifies values for both the \u003ccode\u003e\u003ca href=\"/youtube/v3/docs/commentThreads#snippet.channelId\"\u003esnippet.channelId\u003c/a\u003e\u003c/code\u003e and \u003ccode\u003e\u003ca href=\"/youtube/v3/docs/commentThreads#snippet.videoId\"\u003esnippet.videoId\u003c/a\u003e\u003c/code\u003e properties. A comment that applies to a video appears on the videos watch page.\u003c/li\u003e\u003c/ul\u003e",
"locationType": "other",
"location": "body.snippet"
}
],
"code": 400,
"message": "Each comment thread must be linked to a channel or video.\u003cul\u003e\u003cli\u003eIf the comment applies to a channel, make sure that the resource specified in the request body provides a value for the \u003ccode\u003e\u003ca href=\"/youtube/v3/docs/commentThreads#snippet.channelId\"\u003esnippet.channelId\u003c/a\u003e\u003c/code\u003e property. A comment that applies to a channel appears on the channels \u003cb\u003eDiscussion\u003c/b\u003e tab.\u003c/li\u003e\u003cli\u003eIf the comment applies to a video, make sure the resource specifies values for both the \u003ccode\u003e\u003ca href=\"/youtube/v3/docs/commentThreads#snippet.channelId\"\u003esnippet.channelId\u003c/a\u003e\u003c/code\u003e and \u003ccode\u003e\u003ca href=\"/youtube/v3/docs/commentThreads#snippet.videoId\"\u003esnippet.videoId\u003c/a\u003e\u003c/code\u003e properties. A comment that applies to a video appears on the videos watch page.\u003c/li\u003e\u003c/ul\u003e"
}
}
我找到了解决方案,我很愚蠢,因为参数必须通过对象传递——这里是使用此函数的人的示例
var c = new gapi.client.youtube.commentThreads.insert(
{
"part": "snippet"
},
{
"snippet": {
"channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"videoId": "NeF0zpT4gNE",
"topLevelComment": {
"snippet": {
"textOriginal": "Hello from API"
}
}
}
}
);
c.execute();
var c = new gapi.client.youtube.commentThreads.insert(
{
"part": "snippet"
},
{
"snippet": {
"channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"videoId": "NeF0zpT4gNE",
"topLevelComment": {
"snippet": {
"textOriginal": "Hello from API"
}
}
}
}
);
c.execute();