Youtube API v3 Can't reply or rate on any comment

不羁岁月 提交于 2021-01-28 21:15:42

问题


I am trying to comment and rate a comment via API but the resource is always canRate: false and canReply: false I I've tried through google javascript client and http get request, but nothing seems to be working.

$http.get('https://www.googleapis.com/youtube/v3/commentThreads', {
    params: {
        key: API_KEY,
        part: 'snippet',
        textFormat: 'plainText',
        videoId: VIDEO_ID,
        order: 'relevance'
    }
}).success(function(response) {
    $scope.comments = response.items;
    $log.debug($scope.comments);

    //var author = item.snippet.topLevelComment.snippet.authorDisplayName;
    //var comment = item.snippet.topLevelComment.snippet.textDisplay;
    //var nextToken = results.nextPageToken;
    //var totalRep = item.snippet.totalReplyCount;
    //var parent = item.snippet.topLevelComment.id;
})
.error(function(error) {
    $log.error(error);
})

This is what I'm using, I can list them perfectly (even using v3/comments) but can't reply neither rate a comment, this is what I'm using

gapi.client.load('youtube', 'v3', function () {
    $scope.selectedComment.snippet.viewerRating = 'like';

    var request = gapi.client.youtube.commentThreads.update({
        part: "snippet",
        body: $scope.selectedComment
    });

    request.execute(function(response) {
        $log.debug(response);
    });
});

At the body part I've also tried this

body: {
    id: $scope.selectedCommentId,
    'snippet': {
        'viewerRating': 'like'
    }
}

But I get this error

404 The specified comment thread could not be found. Check the value of the id property in the request body to ensure that it is correct


回答1:


You can replay the comment

POST https://www.googleapis.com/youtube/v3/comments?part=snippet&access_token={YOUR_API_KEY}

body
{
 "snippet": {
  "parentId": "parentCommentID",
  "textOriginal": "yoursComment"
 }
}

You can get more info here https://developers.google.com/youtube/v3/docs/comments/insert#examples



来源:https://stackoverflow.com/questions/35469128/youtube-api-v3-cant-reply-or-rate-on-any-comment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!