Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Youtube comments get deleted after displaying

$
0
0

Good morning,I'm having an annoying problem with some thing that's i'm trying to make using the youtube comment api , i'm trying to add automatically a comment when a video on my channel has been uploaded , it works as intended for the first 5 seconds and i get a notification that my comment was added , ,and i can see it after i uploaded my video , but after 3 - 5 seconds after , my comment gets deleted on it's own.i looked for what could the cause of this could be , and i thought " oh maby it's considered as spam " , so i look in my uploaded video comments spam tab , and NOTHING , the comments are no where to be found.i tried this process for around 10 times and still nothing , can someone help me out please ?Thank you !

Here's what i do :

I subscribe to the youtube webhook to get a notification when a user uploads a new video

when i receive a notification , i send a push notification to my android app , so i can get an access_token from my android app using the google api.

once i get the token , isend it to my server so i can use it to comment on my new video.

Here is the code i use to insert a comment in the backend ( in node js ) :

function insertYoutubeComment(videoId,channel_id,message,access_token,comment){    return new Promise((resolve, reject) => {      request({        method: 'POST',        url: 'https://www.googleapis.com/youtube/v3/commentThreads',        headers: {'User-Agent': 'Request-Promise'        },        body: {"snippet": {"videoId": videoId,"channelId": channel_id,"topLevelComment": {"snippet": {"textOriginal": message              }            }          }        },        qs: {          part: 'snippet',          access_token: access_token        },        json: true      }, function (error, response, body) {        console.log('body ==== ', body);        if (error) {          console.log('body', error.stack);          console.log('error in when posting comment ', error.stack);          resolve(error.stack);     //     return reject(error);        }        console.log("Videos ==== ",comment.video);let videos = comment.videovideos.push(videoId)let bod = {}        console.log("Updating videos ");        Object.assign(bod, {          video: videos,          });console.log("Body in update =====",body);        commentmodel.updateOne(          { _id: comment._id },          bod,          function (err, user) {            if (err) {              console.log("Error updating ")              resolve("comment Error");            } else {              console.log("Updated user ===",user);              resolve("comment inserted");            }          }        );        //res.json({ message: "Comment inserted", status: 200, data: comment });       // return resolve(body);      });    });}

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>