Hi
I have below code . I want to list No of Subscribers Video Wise.
protected void MyOwnVideos() { StringBuilder htmlTable = new StringBuilder(); var client = new RestClient("googleapis.com/youtube/v3"); var request = new RestRequest("search", Method.GET); request.AddParameter("part", "snippet"); request.AddParameter("type", "video"); request.AddParameter("channelId", "UC_nNoaVw"); // Replace with your actual channelId request.AddParameter("key", "AIz8..."); // Replace with your actual API key IRestResponse<YoutubeSearchListResponse> response = client.Execute<YoutubeSearchListResponse>(request); // Check if the response contains data if (response.Data == null || response.Data.items == null || response.Data.items.Count == 0) { Console.WriteLine("No Data Found. Please check your channelId and API key."); return; } // Build the HTML table htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>"); htmlTable.Append("<thead><tr><th>Video Id</th><th>Video Title</th><th>Description</th><th>Published</th></tr></thead>"); htmlTable.Append("<tbody>"); foreach (var data in response.Data.items.OrderBy(x => x.snippet.publishedAt)) { htmlTable.Append("<tr>"); htmlTable.Append($"<td>{data.id}</td>"); htmlTable.Append($"<td>{data.snippet.title}</td>"); htmlTable.Append($"<td>{data.snippet.description}</td>"); htmlTable.Append($"<td>{data.snippet.publishedAt}</td>"); htmlTable.Append("</tr>"); } htmlTable.Append("</tbody>"); htmlTable.Append("</table>"); // Output the HTML table Console.WriteLine(htmlTable.ToString()); } public class YoutubeSearchListResponse { public string kind { get; set; } public string etag { get; set; } public string nextPageToken { get; set; } public string regionCode { get; set; } public PageInfo pageInfo { get; set; } public List<Item> items { get; set; } } public class Snippet { public DateTime publishedAt { get; set; } public string channelId { get; set; } public string title { get; set; } public string description { get; set; } public Thumbnail thumbnails { get; set; } public string channelTitle { get; set; } public string liveBroadcastContent { get; set; } public DateTime publishTime { get; set; } } public class Id { public string kind { get; set; } public string videoId { get; set; } } public class Item { public string kind { get; set; } public string etag { get; set; } public Id id { get; set; } public Snippet snippet { get; set; } }
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.