因此,我的網頁設法通過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