Youtube Analytics API v2迁移

时间:2018-12-03 13:47:07

标签: migration youtube-data-api youtube-analytics-api

由于自2018年11月1日起不赞成使用YouTube Analytics API(第1版),因此我一直在尝试将其迁移到第2版。

我通过以下链接下载了升级表格: https://github.com/googleapis/google-api-php-client-services

,迁移文档如下: enter link description here

以下是代码:

0.57.7

$ api返回空白。

我已经修改了request.query函数,以将更改应用于整个系统。如下所示:路径:google / apiclient-services / src / Google / Service / YoutubeAnalytics / Resources / Reports.php

$youtubeAnalytics       =   new Google_Service_YouTubeAnalytics($client);
$channel                =   "channel==" . $channelId;
$metrics                =   'views,redViews,comments,likes,dislikes,videosAddedToPlaylists,videosRemovedFromPlaylists,shares,estimatedMinutesWatched,estimatedRedMinutesWatched,averageViewDuration,averageViewPercentage,annotationClickThroughRate,annotationCloseRate,annotationImpressions,annotationClickableImpressions,annotationClosableImpressions,annotationClicks,annotationCloses,cardClickRate,cardTeaserClickRate,cardImpressions,cardTeaserImpressions,cardClicks,cardTeaserClicks,subscribersGained,subscribersLost';
$optParams              =   array('dimensions' => 'day'
// to fetch daily analytics
);
$startDate              =   date('Y-m-d');
// for first crawl
$endDate                =   date("Y-m-d", strtotime('-90 days'));
if ($user['last_used'] != '') {
    $endDate            =   date("Y-m-d", strtotime('-10 days')); // if not the first crawl

}

// fetching the daily channel analytics : Youtbe Analytics API
$api                    =   $youtubeAnalytics->reports->query($channel, $endDate, $startDate, $metrics, $optParams);

我在这里没有得到回应: 路径:google> apiclient / src / Google / Service / Resource.php

public function query($ids, $startDate, $endDate, $metrics, $optParams = array())
  {
    $params = array('ids' => $ids, 'startDate' => $startDate, 'endDate' => $endDate, 'metrics' => $metrics);
    $params = array_merge($params, $optParams);
    return $this->call('query', array($params), "Google_Service_YouTubeAnalytics_QueryResponse");
  }

如果问题不正确,我深表歉意。这是我第一次使用Youtube API。请帮忙。

0 个答案:

没有答案