1

As a channel owner I am trying to remove comments posted on my videos and in my discussion section by other users.

I can't find any information on the function in the api documentation. I can call the delete function with a comment id, but it only works on comments that the user who has signed into the api has posted. I'd like to call the same function outlined in this picture and that is available on youtube:

I need to call this remove function from the API

Here's the link to the comment api.

naybro
  • 41
  • 6

2 Answers2

3

The response I got from Google:

"You cannot delete comments that have not been made by your own account. To remove and moderate comments from other users on videos that you own please use the setModerationStatus API documented here: https://developers.google.com/youtube/v3/docs/comments/setModerationStatus"

You can set the moderation status to rejected and it will have the same functionality.

naybro
  • 41
  • 6
1

You will make use of Comments.delete This will require you to pass a commentId to delete a particular comment. There are various ways to fetch the commentId, as for me, I use this URI GET request:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId={VIDEO_ID}&key={API_KEY}

You will get a response like:

"items": [
  {
   "kind": "youtube#commentThread",
   "etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/wQo7nKuPMjPTCeeV9ofDLff8KhY\"",
   "id": "z12ojxq5qwjlulz4o04cc5vxauuaubkbovk0k",
   "snippet": {
    "videoId": "Ez4nKZ2BeTU",
    "topLevelComment": {
     "kind": "youtube#comment",
     "etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/Ifn8tdeFUJiclXThCp44Cib6-cU\"",
     "id": "z12ojxq5qwjlulz4o04cc5vxauuaubkbovk0k", //this is the commentId you will use to delete the comment
     "snippet": {
      "authorDisplayName": "...",
      "authorProfileImageUrl": "...",
      "authorChannelUrl": "...",
      "authorChannelId": {
       "value": "..."
      },
      "videoId": "Ez4nKZ2BeTU",
      "textDisplay": "deleteme\ufeff", //this is my comment which I would like to delete
      ...

Use the commentId and pass that to the Comments.delete Try-it to delete the comment. It will return a 204 status if successful. So that's the concept. Hope this helps.

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
  • 1
    We can delete our own comments, we just can't delete comments placed by other users on our videos and channel discussion. When we try to delete other people's comments using the API we get a 400 error. This is even though we follow OAuth and should have that remove functionality specified above. Thank you though for your response. – naybro Dec 01 '16 at 20:25