youtube api 3.0 getting the info for a single video

php, video, youtube-api

Solution

can't give you the exact php code but the url is something like this

String url = "https://www.googleapis.com/youtube/v3/videos?id="+videoID+"&key=" + YOUR KEY HERE + "&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics";

you get a JSON object that you parse :)

Problem

I'm trying to get the data for a single video with the Youtube api 3.0 in and I can't figure out how to do it. I manage to make this example work pretty easily: https://developers.google.com/youtube/v3/code_samples/php and customize it a bit. But now I'm trying to get the info for a single video with a specific Id. Here what I try ``` $data = $youtube->videos->list("snippet"); ``` and this always give me this error Cannot unset string offsets in {SERVER_PATH}/Google_ServiceResource.php on line 95 If anyone can help I would really appreciate.

Original source