Getting YouTube channel profile picture with channelId

前端 未结 3 990
自闭症患者
自闭症患者 2021-02-05 21:33

So I\'m trying to get the channel profile picture for a YouTube channel by using the channelId.

I would like to do it simply by adding the channelId to a URL and get the

相关标签:
3条回答
  • 2021-02-05 22:16

    In PHP, I got it with:

    $url = "https://www.googleapis.com/youtube/v3/channels?part=snippet&fields=items%2Fsnippet%2Fthumbnails%2Fdefault&id={$channelId}&key={$API}";
    
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    $channelOBJ = json_decode( curl_exec( $ch ) );
    
    $thumbnail_url = $channelOBJ->items[0]->snippet->thumbnails->default->url;
    
    0 讨论(0)
  • 2021-02-05 22:17

    You can use channels->list request for that.

    In response you will get snippet.thumbnails."default".url for that

    For authenticated user's channel:

    GET https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true&fields=items%2Fsnippet%2Fthumbnails&key={YOUR_API_KEY}
    

    Or for any channel ID:

    GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id+CHANNEL_ID&fields=items%2Fsnippet%2Fthumbnails&key={YOUR_API_KEY}
    
    0 讨论(0)
  • 2021-02-05 22:21

    a little bit late, but maybe interesting for others:

    just create a comma separated list for the different channelIds and then call

    https://www.googleapis.com/youtube/v3/channels?part=snippet&id='+commaSeperatedList+'&fields=items(id%2Csnippet%2Fthumbnails)
    

    therefore you don't have to send a request for each item

    0 讨论(0)
提交回复
热议问题