因此,我的网页设法通过Youtube API连接YouTube频道,并保存令牌等。但我没有找到任何代码示例来检索YouTube的个人资料图片。如何检索YouTube频道(PHP)的个人资料图片?
我在去年发现了另一个线程,其中有人用json脚本回答。它看起来如下:
var json = new WebClient().DownloadString("http://gdata.youtube.com/feeds/api/users/"+YT_CHANNEL_NAME);
string str = "thumbnail url='";
string ImagePic = json.Substring(json.IndexOf("thumbnail url") + str.Length);
if (ImagePic.Contains("'"))
{
ImagePic = ImagePic.Remove(ImagePic.IndexOf("'"));
ImageChannel.ImageUrl = ImagePic;
}
我没有在任何JSON的经验和无法弄清楚,如果这仍然是我的一个合适的代码,以及如何实现它在我的PHP代码。
根据文档,您可以访问个人资料图片:https://developers.google.com/youtube/2.0/ developers_guide_protocol_profiles?hl = en – DataHerder
其次,这基本上是服务器端JavaScript,Node.js。你不能直接翻译它,它是与他们自己的实现太不同的脚本语言。这就是说,你看过php-youtube api框架吗?您需要下载该文件,并在此处查看获取用户的答案:http://stackoverflow.com/questions/22117243/getting-user-info-google-php-client-issue – DataHerder