Blu*_*met 6 html youtube youtube-api youtube-data-api
有没有办法直接链接到 YouTube 页面的评论部分?
我知道这可以使用 anchors 和 div ids来完成,但是当我将它应用到 YouTube URL 时这并不成功,因为 YouTube 在页面加载时去掉了正斜杠。
例如,https://www.youtube.com/watch?v=eRsGyueVLvQ/#comments变成?v=eRsGyueVLvQ#comments
这是可能的,还是应该将其归结为功能请求?
小智 5
您可以通过单击发表的时间(例如2 years ago),使某个评论出现在评论部分的顶部。
这将带您到同一个 YouTube 视频,但 URL 看起来像这样:(https://www.youtube.com/watch?v=VIDEO_ID&lc=COMMENT_ID就像在 Rebot 先生的回答中一样)。
您也可以为回复执行此操作。
如果您将使用CommentThreads:list:
返回与 API 请求参数匹配的评论线程列表。
代码片段:
// Sample PHP code for commentThreads.list
function commentThreadsListByVideoId($service, $part, $params) {
$params = array_filter($params);
$response = $service->commentThreads->listCommentThreads(
$part,
$params
);
print_r($response);
}
commentThreadsListByVideoId($service,
'snippet,replies',
array('videoId' => 'kmXXXLBL3Nk'));
Run Code Online (Sandbox Code Playgroud)
然后您可以使用以下 URL 创建链接:
https://www.youtube.com/watch?v=VIDEO_ID&lc=COMMENT_ID
Run Code Online (Sandbox Code Playgroud)
此链接不是在 API 中生成的,因此您应该为此创建一个函数。