你好,我现在在一个使用YouTube api的项目中,我有点困在如何通过使用YouTube获取YouTube内容所有者的前10大通道上。现在,我所做的是,我需要循环所有的渠道,并根据他们的看法排序。
loop {
$analytics = $youtube->reports->query('contentOwner==$content_id', $start_date , $end_date , 'views,comments,likes,dislikes,estimatedMinutesWatched,averageViewDuration,shares,estimatedRevenue,estimatedAdRevenue,monetizedPlaybacks,adImpressions',array('filters'=> $id ,'max-results'=>$max_result));
}这是好的,但由于它需要循环所有的通道,它需要相当长的时间。还有其他方法直接获取前10频道吗?
顺便问一下,还有什么其他途径可以通过用户的同意吗?
发布于 2018-06-26 03:23:13
问题解决后,我做了很多尝试和错误,youtube提供了一个api浏览器,供开发人员立即测试查询参数。

正如我在问题中解释的那样,我已经成功地使用循环获取/检索了通道的数据。
实际上,我只需将每个频道id加上逗号来检索我所管理的所有频道。
在PHP示例之前
loop {
$id = 'channel==' . $id;
$analytics = $youtube->reports->query('contentOwner==$content_id', $start_date , $end_date , 'views,comments,likes,dislikes,estimatedMinutesWatched,averageViewDuration,shares,estimatedRevenue,estimatedAdRevenue,monetizedPlaybacks,adImpressions',array('filters'=> $id ,'max-results'=>$max_result));
}新的或已解决的php示例
$id = 'channel==' . implode(',', $id);
$analytics = $youtube->reports->query('contentOwner==$content_id', $start_date , $end_date,'views,comments,likes,dislikes,estimatedMinutesWatched,averageViewDuration,shares,estimatedRevenue,estimatedAdRevenue,monetizedPlaybacks,adImpressions',array('filters'=> $id ,'max-results'=>$max_result));youtube已经给出了如何使用api的文档,但我认为这是很难理解的。因此,只有在尝试和出错时,我才能使用api。
谢谢。
https://stackoverflow.com/questions/51015715
复制相似问题