我正在嘗試使用 Google Apps 腳本創建一個程式,該程式使用其 ID 插入對給定 youtube 評論的回復。但是當我嘗試插入評論時,它會引發錯誤,
GoogleJsonResponseException:對 youtube.commentThreads.insert 的 API 呼叫失敗并出現錯誤:評論不能為空。[email protected]:42
第 42 行:YouTube.CommentThreads.insert(resource, "snippet");
這是我的代碼:
function startCommentThread(vid,ytch, fc) {
var fc,vid,ytch
fc ="Hi" //This is reply comment
vid ="3a8VpwZm2Kw" //This is video id
ytch ="UCNXOZLBWDbLJxxXcLEpKzVQ" // channel id
const resource = {
snippet: {
channelId: ytch,
videoId: vid,
textOriginal : fc,
parentId : "UgyvUFY31md_zpE9eqV4AaABAg" //comment id
}
}
YouTube.CommentThreads.insert(resource, "snippet");}
uj5u.com熱心網友回復:
該檔案似乎表明您的請求正文的結構不正確。
根據檔案,我認為請求正文應如下所示:
const resource = {
snippet: {
channelId: ytch,
videoId: vid,
topLevelComment: {
snippet: {
textOriginal: fc
}
}
}
};
編輯 我現在看到您只想簡單地插入對現有執行緒的回復。我在您的代碼中注意到您試圖呼叫 YouTube.CommentThreads.insert,所以我認為目標是創建一個新執行緒。
如果您只想回復現有執行緒,并且您已經知道該執行緒的 ID 是什么,則可以像這樣構建資源:
const resource = {
snippet: {
textOriginal: fc,
parentId: threadId // whatever the ID of the parent thread is.
}
};
然后,您將呼叫 YouTube.Comments.insert,而不是 YouTube.CommentThreads.insert。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/532884.html
上一篇:更改下拉選單的外觀
