这是最简单的问题之一,但我无法从论坛到论坛找到答案。我想用php来获取像count这样的视频统计数据。我不想使用cURL来做这件事,我想用SDK和OOP来做。
我无法在任何地方找到我如何使用php构建请求。例如我使用了
$playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
'playlistId' => $uploadsListId,
'maxResults' => 50
));
获取播放列表项,但返回的视频信息不足。我做不到
$youtube->videos->listVideos
请帮帮我。
答案 0 :(得分:1)
PlaylistItems: list返回与API请求参数匹配的播放列表项的集合。
{
"kind": "youtube#playlistItemListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
playlistItem Resource
]
}
每个playlistItem Resource都包含有关播放列表项的信息。
{
"kind": "youtube#playlistItem",
"etag": etag,
"id": string,
"snippet": {
"publishedAt": datetime,
"channelId": string,
"title": string,
"description": string,
"thumbnails": {
(key): {
"url": string,
"width": unsigned integer,
"height": unsigned integer
}
},
"channelTitle": string,
"playlistId": string,
"position": unsigned integer,
"resourceId": {
"kind": string,
"videoId": string,
}
},
"contentDetails": {
"videoId": string,
"startAt": string,
"endAt": string,
"note": string,
"videoPublishedAt": datetime
},
"status": {
"privacyStatus": string
}
}
其中包含可用于运行Videos: getRating的videoId检索授权用户对指定视频列表的评分。
function videosGetRating($service, $id, $params) {
$params = array_filter($params);
$response = $service->videos->getRating(
$id,
$params
);
print_r($response);
}
videosGetRating($service,
'Ks-_Mh1QhMc,c0KYU2j0TM4,eIho2S0ZahI',
array('onBehalfOfContentOwner' => ''));