이젠 도움은 이것 뿐이 못드리겠네요 유트브 뽑기 api > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

이젠 도움은 이것 뿐이 못드리겠네요 유트브 뽑기 api 정보

이젠 도움은 이것 뿐이 못드리겠네요 유트브 뽑기 api

본문

    <title>Listing most viewed videos</title>
    <style type="text/css">
    div.item {
      border-top: solid black 1px;     
      margin: 10px;
      padding: 2px;
      width: auto;
      padding-bottom: 20px;
    }
    span.thumbnail {
      float: left;
      margin-right: 20px;
      padding: 2px;
      border: solid silver 1px; 
      font-size: x-small;
      text-align: center
    }   
    span.attr {
      font-weight: bolder; 
    }
    span.title {
      font-weight: bolder; 
      font-size: x-large
    }
    img {
      border: 0px; 
    }   
    a {
      color: brown;
      text-decoration: none; 
    }
    </style>
  </head>
  <body>
    <?php
    // 피드 URL 설정
    $feedURL = 'http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed';
   
    // 피드를 SimpleXML 객체로 읽음
    $sxml = simplexml_load_file($feedURL);
    ?>
      <h1><?php echo $sxml->title; ?></h1>
    <?php
    // 피드에서 항목을 순회함
    foreach ($sxml->entry as $entry) {
      // get nodes in media: namespace for media information
      $media = $entry->children('http://search.yahoo.com/mrss/');
     
      // 비디오 재생기 URL 얻기
      $attrs = $media->group->player->attributes();
      $watch = $attrs['url'];
     
      // 동영상 축소판 이미지 얻기
      $attrs = $media->group->thumbnail[0]->attributes();
      $thumbnail = $attrs['url'];
           
      // 동영상 길이를 얻기 위해 <yt:duration> 노드 탐색
      $yt = $media->children('http://gdata.youtube.com/schemas/2007');
      $attrs = $yt->duration->attributes();
      $length = $attrs['seconds'];
     
      // 접근 횟수 통계를 얻기 위해 <yt:stats> 노드 탐색
      $yt = $entry->children('http://gdata.youtube.com/schemas/2007');
      $attrs = $yt->statistics->attributes();
      $viewCount = $attrs['viewCount'];
     
      // 동영상 평가 점수를 얻기 위해 <gd:rating> 노드 탐색
      $gd = $entry->children('http://schemas.google.com/g/2005');
      if ($gd->rating) {
        $attrs = $gd->rating->attributes();
        $rating = $attrs['average'];
      } else {
        $rating = 0;
      }
      ?>
      <div class="item">
        <span class="title">
          <a href="<?php echo $watch; ?>"><?php echo $media->group->title; ?></a>
        </span>
        <p><?php echo $media->group->description; ?></p>
        <p>
          <span class="thumbnail">
            <a href="<?php echo $watch; ?>"><img src="<?php echo $thumbnail;?>" /></a>
            <br/>click to view
          </span>
          <span class="attr">By:</span> <?php echo $entry->author->name; ?> <br/>
          <span class="attr">Duration:</span> <?php printf('%0.2f', $length/60); ?>
          min. <br/>
          <span class="attr">Views:</span> <?php echo $viewCount; ?> <br/>
          <span class="attr">Rating:</span> <?php echo $rating; ?>
        </p>
      </div>     
    <?php
    }
    ?>
좋은 스킨/좋은 프로그램만드시길...
높이 나는 새가 멀리본다는 말이 있습니다. 도전하는 자만이  세상을 넓게 볼수 있겠죠 .....
모두가 최고 1인이 될수 있습니다. 노력 하시길 바랍니다.
 
저에게 악의 없는분중 다른 보드에 절 만나시더라도 좋은 인연이 되었으면 좋겠습니다. 이만.... 그누보드 회이팅입니다.!!
추천
4
  • 복사

댓글 4개

© SIRSOFT
현재 페이지 제일 처음으로