https://gdata.youtube.com/feeds/api/videos/GrbUbVHSpzw?v=2&alt=json
<ul> ...... <li data-youtubeid='<?= $v["youtube_id"] ?>'> <a href="<?= $v["link"] ?>"> <img src="//img.youtube.com/vi/<?= $v["youtube_id"] ?>/0.jpg" alt="" width="237px"> </a> <div class="youtube_title"><a href="#"></a></div> <div class="author"></div> <div class="counter"><span></span> просмотров<div class="youtube_date"></div></div> </li> ...... </ul> <script> (function($) { $(function () { $(".yotube-list li").each(function() { var thisli = $(this); var data_create = new Date(); $.getJSON('http://gdata.youtube.com/feeds/api/videos/' + $(this).attr("data-youtubeid") + '?alt=json', function (data) { thisli.find(".youtube_title a").text(data.entry.title.$t); thisli.find(".author").text(data.entry.author[0].name.$t); thisli.find(".counter span").text(data.entry.yt$statistics.viewCount.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ')); var date = new Date(Date.parse(data.entry.updated.$t)); thisli.find(".youtube_date").text(date.format("dd.MM.yyyy").toString()); }); }); //https://gdata.youtube.com/feeds/api/videos/GrbUbVHSpzw?v=2&alt=json }); })(jQuery); </script> </section>
Комментариев нет:
Отправить комментарий