Skrypt przedstawia bibliotekę Php5tube do obsługi youtube z poziomu php.
Pobierz kod biblioteki Php5tube.php [POBIERZ]
Podstawowe możliwości:
- Pobieranie najpopularniejszych filmów video
- Pobranie informacji o użytkowniku youtube
- Pobranie filmów video danego użytkownika
- Pobranie komantarzy danego pliku video
- Pobranie informacji o danym pliku video
include 'Php5tube.php';
$phptube = new Php5tube('Video','User','Comment');
$most_viewed = $php5tube->getMostViewed(1,10);
$user_info = $php5tube->getUserInfo('rickrolled');
$user_vids = $php5tube->getUserVideos('rickrolled','',1,10);
$vid_comments = $php5tube->getVideoComments('oHg5SJYRHA0',1,10);
$vid_info = $php5tube->getVideoInfo('oHg5SJYRHA0');
Listing
//-----------Gotowy przykład----------------------
<?php
//get or create youtube username
if( isset($_GET['user']) ){$youtube_user = $_GET['user'];}
else {$youtube_user = 'rickrolled';}
//create php5tube object and get videos
include_once("Php5tube.php");
$php5tube = new Php5tube('Video','User','Comment');
$videos = $php5tube->getUserVideos($youtube_user);
//dump array of views
//var_dump($videos);
?>
<html>
<head><title></title></head>
<body>
<table cellpadding="0" cellspacing="0">
<?php foreach($videos as $video) { ?>
<tr><td>
<div style="padding:2px;"><img src="<?php echo $video['Video']['thumbnail_url1']; ?>"></div>
<div style="padding:2px;"><img src="<?php echo $video['Video']['thumbnail_url2']; ?>"></div>
<div style="padding:2px;"><img src="<?php echo $video['Video']['thumbnail_url3']; ?>"></div>
</td><td>
<div style="padding:10px;">
<a href="http://www.youtube.com/v/<?php echo $video['Video']['youtube_id']; ?>">
<img src="<?php echo $video['Video']['thumbnail_url4']; ?>">
</a>
</div>
</td>
<td>
<div style="font-size:16pt;"><?php echo $video['Video']['title']; ?></div>
<div><b>Category</b> = <?php echo $video['Video']['category']; ?> times</div>
<div><b>Tags</b> = <?php echo $video['Video']['keywords']; ?> times</div>
<div><b>Description</b> = <?php echo $video['Video']['description']; ?></div>
<div><b>Views</b> = <?php echo $video['Video']['view_count']; ?> times</div>
<div><b>Marked as favorite</b> = <?php echo $video['Video']['favorite_count']; ?> times</div>
</td></tr>
<?php } ?>
</table>
</body>
</html>
Ranga: Administrator serwisu Punktów: 0