Using YouTube API on HTML page with Javascript -
i new web development , trying make simple search page displays youtube videos using youtube api. i've been following examples here: https://developers.google.com/youtube/v3/code_samples/javascript?hl=fr#search_by_keyword i'm not having lot of luck. have no errors no search results either.
my current code here: http://amalthea5.github.io/thinkful-tube/
there seems several problems. need use
<script src="https://apis.google.com/js/client.js?onload=googleapiclientready"></script>
instead of
<script src="https://apis.google.com/js/client.js?onload=onclientload" type="text/javascript"></script>
because need make sure initialization function googleapiclientready()
in auth.js
called.
however, google api reports there exists no oauth client id trusty-sentinel-92304
.
edit:
if don't have oauth client id, rather api key, shouldn't use auth api @ all. instead, need add api key parameter each api call (as described here: https://developers.google.com/youtube/v3/docs/standard_parameters).
try start:
gapi.client.load('youtube', 'v3', function() { var request = gapi.client.youtube.search.list({ key: "your_api_key", q: "cats", part: 'snippet' }); request.execute(function(response) { var str = json.stringify(response.result); console.log(str); }); });
Comments
Post a Comment