Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

youtube api 3.0 getting the info for a single video

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.

like image 894
ChefProg Avatar asked Jul 11 '13 20:07

ChefProg


People also ask

What data can I get from YouTube API?

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.

How do I get a YouTube video title from the YouTube API?

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.


1 Answers

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 :)

like image 85
OWADVL Avatar answered Sep 18 '22 17:09

OWADVL