javascript - Can I make channel list with youtube API if I do not own the channel? I don't receive error but nothing display? -
i trying make channel list, make playlist of videos channel of music, not own channel here https://www.youtube.com/channel/uc-9-kytw8zkzndhqj6fgpwq/featured , want retrieve data channel not own, however.
i thought succeed when did this: https://www.googleapis.com/youtube/v3/channels?id=uc-9-kytw8zkzndhqj6fgpwq&key=aizasyckheobd9nzsmac77nkqqf403mxnxtz35s&part=snippet,contentdetails
but when try put videos on html, nothing shows up, full code:
$(document).ready(function() { $.get ( "https://www.googleapis.com/youtube/v3/channels?id=uc-9-kytw8zkzndhqj6fgpwq&key=aizasyckheobd9nzsmac77nkqqf403mxnxtz35s&part=snippet,contentdetails", function(data) { $.each(data.items, function(i,item) { console.log(item); pid = item.contentdetails.relatedplaylists.uploads; getvids(pid); }) } ); function getvids(pid) { $.get( "https://www.googleapis.com/youtube/v3/playlistitems", { part:'snippet', maxresults: 5, playlistid: pid, key: 'aizasyckheobd9nzsmac77nkqqf403mxnxtz35s' }, function(data) { var output; $.each(data.items, function(i,item) { console.log(item); videtitle = item.snippet.title; output = '<li>'+vidstitle+'</li>' $('#results').append(output); }) } ) } });
i receiving no error title not displaying on html?
yes, can use parameter onbehalfofcontentowner
, parameter can used in authorized request.
the onbehalfofcontentowner
parameter indicates request's authorization credentials identify youtube cms user acting on behalf of content owner specified in parameter value. parameter intended youtube content partners own , manage many different youtube channels. allows content owners authenticate once , access video , channel data, without having provide authentication credentials each individual channel. cms account user authenticates must linked specified youtube content owner.
http request
get https://www.googleapis.com/youtube/v3/channels
if successful, method returns response body following structure:
{ "kind": "youtube#channellistresponse", "etag": etag, "nextpagetoken": string, "prevpagetoken": string, "pageinfo": { "totalresults": integer, "resultsperpage": integer }, "items": [ channel resource ] }
the document shows sample code different supported programming languages: https://developers.google.com/youtube/v3/docs/videos/list#examples
Comments
Post a Comment