我们有一个网站,几个月来一直在使用 YouTube API 为视频加载评论,没有问题。 本周末,我们注意到所有视频中所有评论的评论文本都消失了! 作者信息,publishdAt等都很好,但是片段.textDisplay对于每条评论都是空白的。 如果我在 YouTube.com 上观看视频,评论很好。
示例 API 网址:https://www.googleapis.com/youtube/v3/commentThreads?videoId=1nFywcC37i0&key=PRIVATE_KEY&part=snippet,replies
部分 JSON 返回:
{
"kind": "youtube#commentThreadListResponse",
"etag": ""DsOZ7qVJA4mxdTxZeNzis6uE6ck/HnKLJJvaX5o82p7SOXqZoax63Pk"",
"nextPageToken": "Cg0QvLX3nrHpygIgACgBEhQIAxDQibyJ2oDKAhiwy_Dp193CAhgCIBEo_dG1q83Pj81Z",
"pageInfo": {
"totalResults": 17,
"resultsPerPage": 20
},
"items": [
{
"kind": "youtube#commentThread",
"etag": ""DsOZ7qVJA4mxdTxZeNzis6uE6ck/Fme5IvQu6tqWHp4YOLrYer7CIV0"",
"id": "z12mcbxpbsvvvjpep22qufvxxsqiith5g04",
"snippet": {
"videoId": "1nFywcC37i0",
"topLevelComment": {
"kind": "youtube#comment",
"etag": ""DsOZ7qVJA4mxdTxZeNzis6uE6ck/ldVLSDtTKPhMl-FtaJHj6FzFBxs"",
"id": "z12mcbxpbsvvvjpep22qufvxxsqiith5g04",
"snippet": {
"authorDisplayName": "Tea Culture",
"authorProfileImageUrl": "https://lh3.googleusercontent.com/-gnq7syMNFPM/AAAAAAAAAAI/AAAAAAAABcY/GOY--FZpe0w/photo.jpg?sz=50",
"authorChannelUrl": "http://www.youtube.com/channel/UCLTjm6qRUveEL2-q0UcFjWQ",
"authorChannelId": {
"value": "UCLTjm6qRUveEL2-q0UcFjWQ"
},
"videoId": "1nFywcC37i0",
"textDisplay": "",
"authorGoogleplusProfileUrl": "https://plus.google.com/113856310904021846289",
"canRate": false,
"viewerRating": "none",
"likeCount": 1,
"publishedAt": "2015-12-29T08:58:47.729Z",
"updatedAt": "2015-12-29T08:58:47.729Z"
}
},
"canReply": false,
"totalReplyCount": 0,
"isPublic": true
}
},
{
"kind": "youtube#commentThread",
"etag": ""DsOZ7qVJA4mxdTxZeNzis6uE6ck/74T1pezkd-XvwRlS2TdnS55rMLU"",
"id": "z12egnvgnxubg1fcz23njpizuseusp52v",
"snippet": {
"videoId": "1nFywcC37i0",
"topLevelComment": {
"kind": "youtube#comment",
"etag": ""DsOZ7qVJA4mxdTxZeNzis6uE6ck/Qo_wbi2gLLivL4wxv762XrTrOTc"",
"id": "z12egnvgnxubg1fcz23njpizuseusp52v",
"snippet": {
"authorDisplayName": "speeedskater",
"authorProfileImageUrl": "https://lh6.googleusercontent.com/-vfRKsopq1lU/AAAAAAAAAAI/AAAAAAAAABM/L0ASWMo0cAg/photo.jpg?sz=50",
"authorChannelUrl": "http://www.youtube.com/channel/UCsb8wbZeHZTta_yZ_YN1mag",
"authorChannelId": {
"value": "UCsb8wbZeHZTta_yZ_YN1mag"
},
"videoId": "1nFywcC37i0",
"textDisplay": "",
"authorGoogleplusProfileUrl": "https://plus.google.com/113292370824207410602",
"canRate": false,
"viewerRating": "none",
"likeCount": 0,
"publishedAt": "2015-12-03T05:25:02.538Z",
"updatedAt": "2015-12-03T05:25:02.538Z"
}
},
"canReply": false,
"totalReplyCount": 0,
"isPublic": true
}
},
...
它似乎确实是最近的错误;我将在 http://code.google.com/p/gdata-issues/issues/detail?id=7969 密切关注该报告,并实施解决方法以现在使用textFormat作为纯文本。
如果需要 textFormat html,可以通过请求注释列表来接收注释。将筛选器 ID 设置为在注释线程列表响应中找到的顶级注释的 id。
https://www.googleapis.com/youtube/v3/comments?id=TOP_LEVEL_COMMENT_ID&key=PRIVATE_KEY&part=snippet