【问题标题】:Youtube API v3 Can't reply or rate on any commentYoutube API v3 无法回复或评价任何评论
【发布时间】:2016-05-29 21:22:41
【问题描述】:

我正在尝试通过 API 评论和评价评论,但资源总是 canRate: falsecanReply: false 一世 我已经尝试通过 google javascript 客户端和 http get 请求,但似乎没有任何效果。

$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);
})

这就是我正在使用的,我可以完美地列出它们(即使使用v3/comments)但不能回复也不能评价评论,这就是我正在使用的

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);
    });
});

body 部分,我也试过这个

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

但我得到了这个错误

404 找不到指定的评论线程。检查值 id 属性的 请求正文以确保其正确

【问题讨论】:

    标签: javascript youtube google-api


    【解决方案1】:

    你可以重播评论

    POST https://www.googleapis.com/youtube/v3/comments?part=snippet&access_token={YOUR_API_KEY}
    
    body
    {
     "snippet": {
      "parentId": "parentCommentID",
      "textOriginal": "yoursComment"
     }
    }
    

    您可以在此处获取更多信息 https://developers.google.com/youtube/v3/docs/comments/insert#examples

    【讨论】:

      猜你喜欢
      • 2016-03-24
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 1970-01-01
      • 2016-08-27
      • 2015-10-21
      • 2018-04-14
      • 2017-05-29
      相关资源
      最近更新 更多