Post comments to youtube videos using youtube api

2019-02-19 19:43发布

问题:

How can I add comments on a particular youtube video via my app? Using youtube api v3. I am able to get the comments of a youtube video using this url:

http://gdata.youtube.com/feeds/api/videos/"+VIDEO_ID+"/comments?prettyprint=true

How can I post comments?

回答1:

You can use you tube "CommentThreads: insert" to post your comment via app

https://developers.google.com/youtube/v3/docs/commentThreads/insert

following is the api call

Post url : https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&key={YOUR_API_KEY}

And body for the API call is:

Body

    { "snippet":{
      "topLevelComment":{
       "snippet":{
        "textOriginal": "YOUR_COMMENT_HERE",
        "videoId": "VIDEO_ID"
       }
      }
     }
    }

Also add don't forget to add following scope https://www.googleapis.com/auth/youtube.force-ssl