Hi
Is it possible to get Youtube Subscribers latest video details & Post like to their videos
Thanks
Hi
Is it possible to get Youtube Subscribers latest video details & Post like to their videos
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 11, 2023, 11:28 PM EST
Hello Ramco,
Try below code:
static void GetLatestVideoForSubscribedChannels(string accessToken) { // Set the YouTube API base URL string baseUrl = "https://www.googleapis.com/youtube/v3/"; // Create a new RestClient and set the base URL RestClient client = new RestClient(baseUrl); // Set the request parameters to retrieve the subscribed channels of the authenticated user RestRequest request = new RestRequest("subscriptions", Method.Get); request.AddParameter("part", "snippet"); request.AddParameter("mine", "true"); request.AddHeader("Authorization", "Bearer " + accessToken); // Execute the request and get the list of subscribed channels IRestResponse response = client.Execute(request); dynamic data = Newtonsoft.Json.JsonConvert.DeserializeObject(response.Content); // Loop through the subscribed channels and get the latest video for each channel foreach (var item in data.items) { // Get the channel ID and set the request parameters to retrieve the latest video uploaded by the channel string channelId = item.snippet.resourceId.channelId; request = new RestRequest("search", Method.Get); request.AddParameter("part", "snippet"); request.AddParameter("channelId", channelId); request.AddParameter("order", "date"); request.AddParameter("type", "video"); request.AddParameter("maxResults", "1"); request.AddHeader("Authorization", "Bearer " + accessToken); // Execute the request and get the details of the latest video uploaded by the channel response = client.Execute(request); dynamic videoData = Newtonsoft.Json.JsonConvert.DeserializeObject(response.Content); dynamic video = videoData.items[0]; // Print the details of the latest video Console.WriteLine("Latest video uploaded by " + item.snippet.title + ":"); Console.WriteLine("Title: " + video.snippet.title); Console.WriteLine("Description: " + video.snippet.description); Console.WriteLine("Thumbnail: " + video.snippet.thumbnails.high.url); Console.WriteLine("Video URL: https://www.youtube.com/watch?v=" + video.id.videoId); Console.WriteLine(""); } }Thanks
Naimish Makwana