Reputation: 1619
i need to get the number of subscribers of a youtube channel in my asp.net website, i have searched the documentation (https://developers.google.com/youtube/2.0/developers_guide_protocol_activity_feeds) and i got that i have to put this:
http://gdata.youtube.com/feeds/api/users/PageName
but its not giving anything even when i open it in a browser it wont open any help would be much appreciated.
is there a special library or api i can use?
Upvotes: 1
Views: 1778
Reputation: 6159
What you can do is the following:
System.Net.WebClient wb = new System.Net.WebClient();
string str = wb.DownloadString("http://gdata.youtube.com/feeds/api/users/TheNewYorkTimes");
Response.Write(getCount(str));
public static string getCount(string video)
{
if (video.Contains("="))
{
string str = "subscriberCount='";
string videoid = video.Substring(video.IndexOf("subscriberCount") + str.Length);
if (videoid.Contains("'"))
{
videoid = videoid.Remove(videoid.IndexOf("'"));
return videoid;
}
else
{
return "";
}
}
else
{
return "";
}
}
Upvotes: 1