YouTube 分析 API php 示例 [英] YouTube Analytics API php Samples
本文介绍了YouTube 分析 API php 示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 PHP 客户端库发出此 YouTube 分析请求
I want to make this YouTube Analytics Request with the PHP Client Libary
https://www.googleapis.com/youtube/analytics/v1/reports
?ids=channel==CHANNELID
&start-date=STARTDATE
&end-date=ENDDATE
&metrics=views,
estimatedMinutesWatched,
averageViewDuration,
comments,
favoritesAdded,
favoritesRemoved,
likes,
dislikes,
shares,
subscribersGained,
subscribersLost
&dimensions=7DayTotals
&fields=rows
&sort=day
这可能吗?是否有任何关于如何从 API 获取 YouTube 分析报告的 PHP 代码示例?
在 Google Developers 页面上找不到.(https://developers.google.com/youtube/analytics/v1/code_samples/)
Is this possible?
Are there any PHP code Samples on how the get a YouTube Analytics Report from the API?
Couldn't find one on the Google Developers page .(https://developers.google.com/youtube/analytics/v1/code_samples/)
谢谢
推荐答案
您可以通过以下方式添加指标,而不是一个一个地调用每个指标.
You can add metrics in the following way rather than calling each metric one by one.
$metrics = 'views,estimatedMinutesWatched,averageViewDuration,comments,favoritesAdded,favoritesRemoved,likes,dislikes,shares,subscribersGained,subscribersLost';
您的结果将在文档中描述的 from 中.示例:
Your result will be in the from as depicted in the documentation. Example:
$optparams = array(
'dimensions' => '7DayTotals',
'sort' => 'day',
);
$metrics = 'views,estimatedMinutesWatched,averageViewDuration,comments,favoritesAdded,favoritesRemoved,likes,dislikes,shares,subscribersGained,subscribersLost';
$api_response = $metrics;
$api = $analytics->reports->query($id, $start_date, $end_date, $metric, $optparams);
if (isset($api['rows'])) {
//Get values in form of multidimensional arrays.
}
这篇关于YouTube 分析 API php 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文