Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  28] [ 7]  / answers: 1 / hits: 76928  / 15 Years ago, thu, november 19, 2009, 12:00:00

I'm playing now with the Youtube API and I began a small project (for fun).



The problem Is that I cant find the way to get Title of a video from the Id. (example: ylLzyHk54Z0)



I have looked in the DATA and PLAYER api documentation and I cannot find it.



If someone knows how to do this or if someone could help me find the way to do this, please help me.



NOTE: I'm using javascript. It will be a web app.



EDIT: I have got an Idea. Maybe using a Regular expresion to parse out the title from the page title. I'm working on this.


More From » api

 Answers
8

Not entirely possible in javascript since you are trying to get a document from a different domain. If you are happy to throw in a bit of php try this. Tested ok:



<?
$vidID = $_POST['vidID'];
$url = http://gdata.youtube.com/feeds/api/videos/. $vidID;
$doc = new DOMDocument;
$doc->load($url);
$title = $doc->getElementsByTagName(title)->item(0)->nodeValue;
?>

<html>
<head>
<title>Get Video Name</title>
</head>
<body>
<form action=test.php method=post>
<input type=text value=ID Here name=vidID />
<input type=submit value=Get Name />
</form>
<div id=page>URL: [<?= $url ?>]</div>
<div id=title>Title: [<?= $title ?>]</div>
</body>
</html>

[#98280] Sunday, November 15, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marisela

Total Points: 103
Total Questions: 105
Total Answers: 102

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
;