我正在从视频中获取评论,但“作者姓名”和他们的 ID 为 NULL。
这就是我所拥有的。
$feedUrl='http://gdata.youtube.com/feeds/api/videos/'.$selected_video_id.'/comments?v=2&alt=json';
$data = json_decode(file_get_contents($feedUrl),true);
$info = $data["feed"];
$entry = $info["entry"];
$nEntry = count($entry);
for($i=0;$i<$nEntry;$i++){
$name = $entry[$i]['author']['name']['$t'];
$userId = $entry[$i]['author']['yt$userId']['$t'];
$content = $entry[$i]['content']['$t'];
$published_2 = $entry[$i]['published']['$t'];
}
Content 和 Published 收集得很好,但 name 和 userID 没有。
提要中确实包含在 youtube 数据 api 演示测试版中查看的元素。如果您在浏览器中执行提要请求,它还会显示所有内容。
http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments
所以我错过了什么吗?