如何计算 YouTube 频道的总观看次数? [英] How to count the total number of views from a youtube channel?

查看:41
本文介绍了如何计算 YouTube 频道的总观看次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 PHP 中的 Youtube API 从 youtube 上的频道获取总观看次数(所有视频).我没有找到任何方法来做到这一点.有没有人有想法?预先感谢您的帮助.

I want to get the total amount of views (all videos) from a channel on youtube using the Youtube API in PHP. I didn't found any method to do that. Does anyone have en idea ? Thanks in advance for your help.

推荐答案

您可以使用新的 YouTube 分析 API

You can use the new YouTube Analytics API

https://developers.google.com/youtube/analytics/v1/available_reports

您可以修改示例应用的代码来调用客户端的api:

you can modify the code of the sample application to call the api in the client side:

https://developers.google.com/youtube/analytics/v1/示例应用程序

并执行类似操作以获得每天的观看次数:

and do something like this to get the number of views per day:

var request = gapi.client.youtubeAnalytics.reports.query({
      // Convert dates to YYYY-MM-DD strings for start-date and end-date parameters.
      'start-date': formatDateString(lastWeek),
      'end-date': formatDateString(today),
      // Identify channel for which you're retrieving data.
      ids: 'channel==' + channelId,
      dimensions: 'day',
      metrics: 'views'
    });

这篇关于如何计算 YouTube 频道的总观看次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆