ฉันกำลังพยายามแสดงความคิดเห็นและให้คะแนนความคิดเห็นผ่าน API แต่ทรัพยากรนั้นเป็น canRate: false
และ canReply: false
เสมอ ฉันได้ลองผ่านไคลเอนต์ Google Javascript และ http รับคำขอแล้ว แต่ดูเหมือนว่าจะไม่มีอะไรทำงาน
$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
ในเนื้อหาคำขอเพื่อให้แน่ใจว่าถูกต้อง