未记录的函数 - gapi.client.youtube.commentThreads.insert [英] Undocumented function - gapi.client.youtube.commentThreads.insert
问题描述
当我浏览 Google YouTube DATA API 并发现对象 gapi.client.youtube.commentThreads.insert 时,我尝试使用它,但我不知道如何使用它,并且 Data API 文档并没有详细说明它,Google 使用 buildApiRequest 函数创建请求.
我尝试编写和运行上面这样的代码,但它返回错误 400
When I was browsing Google YouTube DATA API and I found object gapi.client.youtube.commentThreads.insert, I tried to use it but I didn't know how to use it and Data API documentation doesn't tell much about it, insted of this Google uses buildApiRequest function to create request.
I tried to write and run code like this above, but it returns error 400
代码:
var c = new gapi.client.youtube.commentThreads.insert(
{
"part":"snippet"
},{
'snippet.channelId': 'UC_x5XG1OV2P6uZZ5FSM9Ttw',
'snippet.videoId':'NeF0zpT4gNE',
'snippet.topLevelComment.snippet.textOriginal':'Hello from API'
});
c.execute();
回复
{
"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"
}
}
推荐答案
我找到了解决方案,我很愚蠢,因为参数必须通过对象传递 - 这是使用此功能的人的示例.
I found solution, I was stupid because parameters must be passed by object - here is example for someone who would use this function.
var c = new gapi.client.youtube.commentThreads.insert(
{
"part": "snippet"
},
{
"snippet": {
"channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"videoId": "NeF0zpT4gNE",
"topLevelComment": {
"snippet": {
"textOriginal": "Hello from API"
}
}
}
}
);
c.execute();
这篇关于未记录的函数 - gapi.client.youtube.commentThreads.insert的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!