我管理一个 YouTube CMS,并试图计算给定月份内的上传次数。一个 CMS 可以有多个频道,我想要上传的总数。
从文档中,我觉得这应该可行:
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 中管理的频道的视频。
作为参考,API 文档说:
forContentOwner 参数将搜索限制为仅检索由 onBehalfOfContentOwner 参数标识的内容所有者拥有的视频。如果 forContentOwner 设置为 true,则请求还必须满足以下要求: onBehalfOfContentOwner 参数是必需的。授权请求的用户必须使用与指定内容所有者关联的帐户。type 参数值必须设置为 video。不能设置以下其他参数:videoDefinition、videoDimension、videoDuration、videoLicense、videoEmbeddable、videoSyndicated、videoType。