Reputation: 181
This is one of the most simple questions, but I cannot find the answer anywhere from the docs to forums. I want to use php to get videos stats such as like count. I do not want to do this using cURL, I want to do it using the SDK and OOP.
I cannot find anywhere how I am meant to structure requests as such using php .for example I have used
$playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
'playlistId' => $uploadsListId,
'maxResults' => 50
));
to get playlist items, but not enough video info is returned. I cannot do
$youtube->videos->listVideos
Please help me.
Upvotes: 0
Views: 563
Reputation: 117291
PlaylistItems: list Returns a collection of playlist items that match the API request parameters.
{
"kind": "youtube#playlistItemListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
playlistItem Resource
]
}
Each playlistItem Resource contains information about the playlist item.
{
"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
}
}
Which includes a videoId which can be used to run Videos: getRating Retrieves the ratings that the authorized user gave to a list of specified videos.
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' => ''));
Upvotes: 1