使用channelId获取YouTube频道个人资料图片 [英] Getting YouTube channel profile picture with channelId

查看:206
本文介绍了使用channelId获取YouTube频道个人资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试使用channelId获取YouTube频道的频道个人资料图片.

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

我想简单地通过将channelId添加到URL并以这种方式获取图像来做到这一点. Facebook在使用此URL的地方也有类似之处:

I would like to do it simply by adding the channelId to a URL and get the image that way. Facebook has something similar where you use this URL:

http://graph.facebook.com/user_id/picture?type=square

Google+也拥有它,在这里找到了这个问题.遗憾的是,它不适用于YouTube(我无法使其正常工作)

Google+ has it too, found this question here. Sadly it didn't work for YouTube (I couldn't get it to work)

希望有人可以解决!

先谢谢您了:)

推荐答案

在PHP中,我得到了:

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;

这篇关于使用channelId获取YouTube频道个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆