youtube - YouTube API-在一段时间内计算上传次数

标签 youtube youtube-api youtube-data-api youtube-analytics-api

我管理一个YouTube CMS,并试图计算给定月份内的上传数量。一个CMS可以有多个 channel ,我想要上传的总数。

从文档中,我觉得这应该可行:

function videosList($service, $part, $params) {
    $params = array_filter($params);
    $response = $service->search->listSearch($part,$params);
    print_r($response);
}

videosList($youtube,"snippet",array(
    array('forContentOwner' => true),
    'type' => 'video',
    'maxResults' => 1,
    'onBehalfOfContentOwner' => $CMSID,
    'publishedBefore' => date("c",strtotime("first day of this month")),
    'publishedAfter' => date("c",strtotime("first day of last month"))            
));

但是结果是列出了时间范围内的所有公开视频,而不仅仅是我在$ CMSID中管理的 channel 中的那些视频。

作为引用,API文档说:

The forContentOwner parameter restricts the search to only retrieve videos owned by the content owner identified by the onBehalfOfContentOwner parameter. If forContentOwner is set to true, the request must also meet these requirements: The onBehalfOfContentOwner parameter is required. The user authorizing the request must be using an account linked to the specified content owner. The type parameter value must be set to video. None of the following other parameters can be set: videoDefinition, videoDimension, videoDuration, videoLicense, videoEmbeddable, videoSyndicated, videoType.

最佳答案

如果引用documentation,则会看到缺少的部分可以在其中使用forMine参数。正如本SO post中讨论的那样。

forMine boolean

This parameter can only be used in a properly authorized request. The forMine parameter restricts the search to only retrieve videos owned by the authenticated user. If you set this parameter to true, then the type parameter's value must also be set to video. In addition, none of the following other parameters can be set in the same request: videoDefinition, videoDimension, videoDuration, videoLicense, videoEmbeddable, videoSyndicated, videoType.



当您检查another SO post时,在这里还引用了:

The problem is the conflicting search restrictions that you used. To make your search work, leave the forMine parameter empty so it doesn't conflict with your date filters and possibly the q parameter as well.

关于youtube - YouTube API-在一段时间内计算上传次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48411056/

相关文章:

c# - 比较互联网上的两个文件是否相同

javascript - 使用 API 从视频 ID 获取 YouTube 文件 URL

php - YouTube API-如何获取最近30天的 channel 观看次数

javascript - 如何检索我的 YouTube channel 播放列表?

android - YouTube android 应用程序如何选择视频编解码器?

javascript - 使Vimeo或youtube在模式打开时播放,并在模式关闭时停止视频播放

r - 如何将 “get caption”函数应用于列中的每一行?

matlab - MATLAB中的YouTube视频统计信息

java - 如何使用java按计数从youtube播放列表中获取视频?

python - YouTube数据API V3-类似于注释和commentThreads