youtube api v3 search by keyword javascript

后端 未结 3 1831
眼角桃花
眼角桃花 2021-01-16 12:16

The javascript example for \"search by keyword\" that is given at the google developers page isn\'t working for me. https://developers.google.com/youtube/v3/code_samples/ja

3条回答
  •  无人及你
    2021-01-16 13:14

    Thanks so much jlmcdonald for your help. It took me a while to figure out the second part of your response, but I finally had success. The following html gets the example on the google developers webpage to work. Note though, at first I was getting a 401 error. To fix it, I had to go to the google developers console and select my project. Then, APIs&auth->consent screen and then fill in the email address and product name:

    
    
      
      Search
      
      
       
    This application requires access to your YouTube account. Please authorize to continue.

    As you noted in your response, oAuth2 isn't necessary for a simple keyword search. The following is some html that just uses the API key. I didn't reference the two .js files like before, rather, I just included the script in the html. Your post at gapi.client.youtube is undefined? really helped me figure it out:

    
    
    
    Search
    
    
      

    Now that I got the search part, could you explain how I can display the thumbnails and titles of the results and then when I click them, the video opens in an embedded player on the same page? Thanks.

提交回复
热议问题