Anpassungen sind per $q, $author, $orderby, ... möglich 🙂

  1. header('Content-type: text/html; charset=utf-8');
  2.  
  3. $q = ''; // Suchbegriffe
  4. $author = 'dodokay2'; // nur Video von diesem Autor anzeigen
  5. $orderby = 'published'; // geordnet nach ...
  6. $startindex = '1'; // beim wie vielten Video soll die Ausgabe starten ?
  7. $maxresults = '2'; // wie viele Videos sollen angezeigt werden ?
  8. $autoplay = '0'; //0 for false, 1 for true
  9. $loop = '0'; //0 for false, 1 for true
  10. $v = '2'; // Version der API-Einbettung
  11.  
  12. // nebenbei: der Parameter &ap=%2526fmt%3D18 erzeugt HQ-Videos, &ap=%2526fmt%3D22 HD-Videos
  13.  
  14. // Leerzeichen muessen durch + ersetzt werden
  15. $q = str_replace(" ", "+", $q);
  16.  
  17. function getYouTubeVideos(){
  18.     $xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos?q='.$GLOBALS['q'].'&author='.$GLOBALS['author'].'&orderby='.$GLOBALS['orderby'].'&start-index='.$GLOBALS['startindex'].'&max-results='.$GLOBALS['maxresults'].'&autoplay='.$GLOBALS['autoplay'].'&loop='.$GLOBALS['loop'].'&v='.$GLOBALS['v'].'');
  19.     foreach($xml->entry as $video){
  20.         $res[] = $video;
  21.     }
  22.     return $res;
  23. }
  24.  
  25. foreach(getYouTubeVideos() as $video){
  26.     $video->link['href'] = str_replace("watch?v=", "v/", $video->link['href']);
  27.     ?>
  28. echo $video->title; ?>

  29.  
  30.      echo $video->link['href']; ?>&hl=de&fs=1">
  31.      echo $video->link['href']; ?>&hl=de&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295">
  32. }
  33. ?>

Deine Meinung zu diesem Artikel?