Youtube API - only the name

I know that I can get all the information about the video using:

http://gdata.youtube.com/feeds/api/videos/ID

but this outputs a lot of information, and im uses a regular expression to get the name from it. I was wondering if there is a way for this page to display only the title, and not all other materials that I donโ€™t need.

+6
php youtube youtube-api
source share
5 answers

Not sure if this will help as I have never worked with youtube api before. I just looked at this information yesterday. According to http://dl.google.com/googleio/2010/googleapis-how-google-builds-apis.pdf you can do Partial Get (just search this pdf for โ€œPartial answerโ€) with fields=entry(title) (although I think it is for video search). By requesting the actual video ID instead of a string, it will return only one video.

Example:

 http://gdata.youtube.com/feeds/api/videos?v=2&q=[video_id]&max-results=1&fields=entry(title)&prettyprint=true 
+6
source share
 <? $id = 'VIDEOID'; $xmlData = simplexml_load_string(file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$id}?fields=title")); $title = (string)$xmlData->title; echo $title; 
+4
source share

http://gdata.youtube.com/feeds/api/videos/[ID]? = Header Fields

experimental, but working.

+2
source share

It returns an XML file, so use simpleXML to parse it.

+1
source share

Prefix search term with "title:", for example:

 http://gdata.youtube.com/feeds/base/videos?q=title:<search term> 
0
source share

All Articles