Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

embed youtube search results into website

<!doctype html>
<html>
  <head>
  <title>Search</title>
  </head>
  <body>
    <div id="buttons">
    <label> <input id="query" value='cats' type="text"/><button id="search-button"    onclick="keyWordsearch()">Search</button></label>    
    <div id="container">
    <h1>Search Results</h1>
    <ul id="results"></ul>
    </div>           
<script>
 function keyWordsearch(){
    gapi.client.setApiKey('api_key_here');
    gapi.client.load('youtube', 'v3', function(){
            makeRequest();
    });
}
function makeRequest(){
    var q = $('#query').val();
    var request = gapi.client.youtube.search.list({
            q: q,
            part: 'snippet', 
            maxResults: 10
    });
    request.execute(function(response)  {                                                                                    
            $('#results').empty()
            var srchItems = response.result.items;                      
            $.each(srchItems, function(index, item){
            vidTitle = item.snippet.title;  
            vidThumburl =  item.snippet.thumbnails.default.url;                 
            vidThumbimg = '<pre><img id="thumb" src="'+vidThumburl+'" alt="No  Image  Available." style="width:204px;height:128px"></pre>';                   

            $('#results').append('<pre>' + vidTitle + vidThumbimg +   '</pre>');                      
    })  
  })  
}
 </script> 
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
 <script src="https://apis.google.com/js/client.js?onload=googleApiClientReady">   </script>
</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Typescript :: fgets input from user 
Typescript :: typescript generic object 
Typescript :: google sheets countif two conditions 
Typescript :: typescript array of objects 
Typescript :: ts generics 
Typescript :: nestjs mongoose schema 
Typescript :: types of variables typescript 
Typescript :: boto3 Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4 
Typescript :: cannot find file does not match the corresponding name on disk 
Typescript :: pass function as argument typescript 
Typescript :: spyon observable 
Typescript :: isnull or empty typescript 
Typescript :: typescript class validator validate enum array 
Typescript :: avatar image mui not centeered 
Typescript :: class-validator not working nest-typescript-starter 
Typescript :: angular animation done event type typescript 
Typescript :: return n elements from list java 
Typescript :: how to keep only certian objects python 
Typescript :: outputs i angular 
Typescript :: paragraph dots after 2 lines css 
Typescript :: print array elements with space c++ 
Typescript :: what is data type in data structure 
Typescript :: nest js http exceptions 
Typescript :: google sheets query multiple or 
Typescript :: excel check if value exists in range 
Typescript :: world-times-newspaper-magazine-style-ghost-blog-theme 
Typescript :: laravel websockets pusher 
Typescript :: copy all elements from one list to another ajav 
Typescript :: terminal update file metadata 
Typescript :: porque la ejecución de scripts está deshabilitada en este sistema 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =