我想使這個YouTube數據分析請求的PHP客戶端Libary的YouTube Analytics(分析)API PHP示例
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
這可能嗎? 是否有任何PHP代碼示例瞭解如何從API獲取YouTube分析報告? 。
$analytics = new Google_YouTubeAnalyticsService($client);
// $client is your Google_Client object
// here we set some params
$id = 'channel==CHANNELID'
$start_date = 'YYYY-MM-DD';
$end_date = 'YYYY-MM-DD';
$optparams = array(
'dimensions' => '7DayTotals',
'sort' => 'day',
);
$metrics = array(
'views',
'estimatedMinutesWatched',
'averageViewDuration',
'comments',
'favoritesAdded',
'favoritesRemoved',
'likes',
'dislikes',
'shares',
'subscribersGained',
'subscribersLost'
);
$api_response = $metrics;
// You can only get one metric at a time, so we loop
foreach ($metrics as $metric)
{
$api = $analytics->reports->query($id, $start_date, $end_date, $metric, $optparams);
if (isset($api['rows'])) $api_response[$metric] = $api['rows'][0][0];
}
編輯:
找不到一個谷歌開發者頁面上(https://developers.google.com/youtube/analytics/v1/code_samples/)
感謝