Wednesday, August 10, 2011

Youtube Data API

Below is a PHP script that uses Youtube API through xml to show the comments on your personal website.

I didn't include any CSS.
Use this link a reference
http://code.google.com/intl/it-IT/apis/youtube/2.0/developers_guide_protocol.html

<?php

//// video id
$videoId='M1Wm9nGJcYo';

//echo the video
echo "";

// url where feed is located
$url="http://gdata.youtube.com/feeds/api/videos/$videoId/comments";

// get the feed
$comments=simplexml_load_file($url);

// parse the feed using a loop
foreach($comments->entry as $comment)
{
echo '
'. $comment->content .'
'. $comment->author->name .'
';
}



?>

No comments:

Post a Comment