javascript - add youtube comments with youtube API and node.js -
i managed fetch video data channel when try add comments video, fail. @ point can read data successfully.
i have read docummentation: https://developers.google.com/youtube/v3/docs/commentthreads/insert
and im not sure if did parameters correctly.
besides node.js , express im using request-promise package promises if thats worth mention.
const optionscomment = { method: 'post', uri: 'https://www.googleapis.com/youtube/v3/commentthreads', qs: { part: 'snippet', 'snippet.channelid': 'a channel id', 'snippet.videoid': 'some video id', 'snippet.toplevelcomment.snippet.textoriginal': 'a nice message', key: "my key" }, json: true }; rp(optionscomment) .then(result=>{ console.log("result of adding comment:", result); }) .catch(function(err){ console.log("error during add comment"); console.log(err); });
when run code retriev error:
error during add comment
{ statuscodeerror: 401 - {"error":{"errors":[{"domain":"global","reason":"required","message":"login required","locationtype":"header","location":"authorization"}],"code":401,"message":"login required"}} @ new statuscodeerror
even if im logged in , try comment own video error.
maybe can give me hint.
thank you!
Comments
Post a Comment