How to get data of a youtube playlist in JSON format using JavaScript API V3 -
youtube stopped support v2 i'm using till now, can tell me how data of youtube playlist in json format using javascript api v3
v2 url used given below http://gdata.youtube.com/feeds/api/playlists/{playlist_id}?alt=json-in-script&callback=showmyvideos
resolved
v3 url https://www.googleapis.com/youtube/v3/playlistitems?part=snippet&maxresults=50&playlistid={playlist_id}&key={key}
there number of sample applications javascript v3 client library can found here:
https://developers.google.com/youtube/v3/code_samples/javascript
the call after playlistitems:list
, can seen here:
https://developers.google.com/youtube/v3/docs/playlistitems/list
and can called using:
get https://www.googleapis.com/youtube/v3/playlistitems?part=snippet&id=your-playlist-id&key={your_api_key}
something along these lines details of first 50 records in specified playlist using javascript client library. result stored in response
object.
<!doctype html> <html> <head> <title>youtube</title> </head> <body> <script> function ongoogleload() { gapi.client.setapikey('{your-api-key}'); gapi.client.load('youtube', 'v3', function() { var request = gapi.client.youtube.playlistitems.list({ part: 'snippet', playlistid: '{playlist-id-here}', maxresults: 50 }); request.execute(function(response) { (var = 0; < response.items.length; i++) { console.log(response.items[i].snippet.title + " published @ " + response.items[i].snippet.publishedat) } }); }); } </script> <script src="https://apis.google.com/js/client.js?onload=ongoogleload"></script> </body> </html>
Comments
Post a Comment