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.
The API provides the ability to retrieve feeds related to videos, users, and playlists. It also provides the ability to manipulate these feeds, such as creating new playlists, adding videos as favorites, and sending messsages.
In order to make a request to the API, you can use jQuery's getJSON() call to request the title from YouTube via AJAX. YouTube's v3 Data API provides 3 endpoints that can be used to get the title: Snippet Title - The video's title.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With