我如何 post 对 YouTube 视频发表评论? (Node.js)

How can I post a comment on a YouTube video? (Node.js)

我想 post 使用 google-api-nodejs-client 以编程方式对 YouTube 视频发表评论。我该怎么做?

如果能提供代码示例,我将不胜感激。

谢谢!

我做到了!

这是代码,以防有人在寻找答案。

var oauth2Client = new OAuth2("CLIENT_ID", "CLIENT_SECRET", []),
    google = require('googleapis'),
    ytdapi = google.youtube('v3');

oauth2Client.setCredentials({
  refresh_token: "REFRESH_TOKEN"
});

var params = {
    auth: oauth2Client,
    part: "snippet",
    resource: {
      snippet: {
        channelId: "CHANNEL_ID",
        videoId: "VIDEO_ID",
      topLevelComment: {
        snippet: {
          textOriginal: "YOUR TEXT HERE"
        }
      }
    }
  }
};


ytdapi.commentThreads.insert(params, function(err, data) {
  if (err) {
    console.log(err);
    res.status(400).send("Error posting comment ");
  }
  else {
    console.log(data);
    res.status(200).send("Successfully posted comment ");
  }
});