Results 1 to 4 of 4

Thread: Looking for jQuery or PHP script that loads a specific youtube users videos into <ul>

  1. #1
    Join Date
    Oct 2008
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Looking for jQuery or PHP script that loads a specific youtube users videos into <ul>

    Hey,

    A client has requested that their videos page content is their youtube user's videos and for them to be loaded in automatically so that their latest upload is always the first video on the page.

    I have been searching for a way to do this and haven't much.

    However i did find this script:

    Code:
    $(function() {
        $.getJSON('http://gdata.youtube.com/feeds/users/[USERNAME]/uploads?alt=json-in-script&callback=?&max-results=10', function(data) { 
            $.each(data.feed.entry, function(i, item) {
    	    var title = item['title']['$t'];
    	    var video = item['id']['$t'];
    	    video = video.replace('http://gdata.youtube.com/feeds/videos/','http://www.youtube.com/watch?v=');
    	    $('#youtube').append('<a href="'+video+'">'+title+'</a> <br/>');
            });
        });
    });
    This code gives me the right data i need.
    A specific youtube user's videos title and url.

    What I want to achieve, is to load this data into a <ul>

    Example:

    Code:
    <ul id="videolist">
        <li class="videos">
            <p class="videoTitle">Video Title</p>
    	<div class="videoURL">Embedded Youtube video</div>                                
        </li> 
        <li class="videos">
            <p class="videoTitle">Video Title</p>
            <div class="videoURL">Embedded Youtube video</div>                                
        </li>                                                            
    </ul>

    Any suggestions or help are very much appreciated.

    Thanks
    Last edited by RipzCurlz; 08-04-2010 at 05:24 AM.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Assuming you mean this code snippet: http://snipplr.com/view.php?codeview&id=26192

    This should do what you want;
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>jquery+json+youtube api test</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript">$(function() {
        $.getJSON('http://gdata.youtube.com/feeds/users/fristopher/uploads?alt=json-in-script&callback=?&max-results=10', function(data) { 
            $.each(data.feed.entry, function(i, item) {
    	    var title = item['title']['$t'];
    	    var video = item['id']['$t'];
    	    video = video.replace('http://gdata.youtube.com/feeds/videos/','http://www.youtube.com/v/');
    	    $('#youtube').append('<li class="videos"><p class="videoTitle">' +title+ '</p><div class="videoURL"><object width="480" height="385"><param name="movie" value="'+video+'&amp;hl=en_GB&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+video+'&amp;hl=en_GB&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></div></li>');
            });
        });
    });
    </script>
    
    </head>
    
    <body>
    
    <ul id="videolist">
    <div id="youtube"></div>
    </ul>
    
    </body>
    </html>
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    RipzCurlz (08-05-2010)

  4. #3
    Join Date
    Oct 2008
    Posts
    13
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    This worked Great!

    The time and effort you put into helping me with this is very very much appreciated.

    Thanks!!

  5. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    no problem RipzCurlz - glad to help
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •