我管理一个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
booleanThis 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 theq
parameter as well.
关于youtube - YouTube API-在一段时间内计算上传次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48411056/