Advertisement
lobosjr

Untitled

Oct 13th, 2015
1,277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public void UpdateSubs(string channel)
  2. {
  3. using (var w = new WebClient())
  4. {
  5. //w.UseDefaultCredentials = true;
  6. //w.Credentials = new NetworkCredential("lobosjr", oAuthToken);
  7. w.Proxy = null;
  8. string url = "https://api.twitch.tv/kraken/channels/" + channel + "/subscriptions?limit=100&offset=0";
  9. while (true)
  10. {
  11. try
  12. {
  13.  
  14. var json = w.DownloadString(string.Format(url));
  15. SubscriberData.RootObject subs = JsonConvert.DeserializeObject<SubscriberData.RootObject>(json);
  16. int numSubs = subs.subscriptions.Count();
  17. if (numSubs == 0)
  18. {
  19. break;
  20. }
  21.  
  22. for (int i = 0; i < numSubs; i++)
  23. {
  24. subsList.Add(subs.subscriptions[i].user.display_name);
  25. url = subs._links.next;
  26. }
  27. }
  28. catch (Exception e)
  29. {
  30. Console.WriteLine("Exception: " + e);
  31. }
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement