migration - Youtube 分析 API v2 迁移
问题描述
由于 YouTube Analytics API (v1) 自 2018 年 11 月 1 日起已弃用(来源),我一直在尝试将其迁移到 v2。
我下载了以下链接的升级表格: https ://github.com/googleapis/google-api-php-client-services
迁移文档如下: 在此处输入链接描述
以下是代码:
$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);
$api 返回空白。
我修改了 request.query 函数以在整个系统中应用更改。如下: 路径:google/apiclient-services/src/Google/Service/YoutubeAnalytics/Resources/Reports.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");
}
我在这里没有得到回复:路径:google > apiclient/src/Google/Service/Resource.php
$request = new Request(
$method['httpMethod'],
$url,
['content-type' => 'application/json'],
$postBody ? json_encode($postBody) : ''
);
如果问题感觉不正确,我深表歉意。这是我第一次使用 Youtube API。请帮忙。
解决方案
推荐阅读
- apache-nifi - Apache Nifi 中的长时间戳不正确
- java - 如何在 Simulink 中使用 S 函数运行 Java 程序?
- batch-file - 如果找到的文件夹没有另一个同名的子文件夹,请执行操作
- node.js - 如何从谷歌助手的用户那里获取文本,并从 sqlite db 响应某些内容
- javascript - 为什么 Await 不阻塞下一行代码?
- swift - 向我的 Swift 应用程序添加了一个命令行目标,但它看不到项目的其余部分
- android - 如何在房间数据库类中获取或观察实时数据
- python - 如何使用 Python 正则表达式查找所有有字母的单词在其中出现两次?
- javascript - 我无法重新分配提示结果
- python - 使用 Series.plot() 绘制每小时数据