/// <summary> /// Returns badges for a given user. /// </summary> /// <param name="USER_ID">ID for user to view badges for..</param> public static FourSquareBadgesAndSets UserBadges(string USER_ID, string AccessToken) { if (USER_ID.Equals("")) { USER_ID = "self"; } HTTPGet GET = new HTTPGet(); string EndPoint = "https://api.foursquare.com/v2/users/" + USER_ID + "/badges?callback=XXX&v=" + Version + "&oauth_token=" + AccessToken; GET.Request(EndPoint); Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody); FourSquareBadgesAndSets BadgesAndSets = new FourSquareBadgesAndSets(JSONDictionary); return BadgesAndSets; }
/// <summary> /// Returns badges for a given user. /// </summary> /// <param name="USER_ID">ID for user to view badges for..</param> public static FourSquareBadgesAndSets UserBadges(string USERID, string AccessToken) { FourSquareBadgesAndSets BadgesAndSets = new FourSquareBadgesAndSets(); if (USERID.Equals("")) { USERID = "self"; } HTTPGet GET = new HTTPGet(); string EndPoint = "https://api.foursquare.com/v2/users/" + USERID + "/badges?oauth_token=" + AccessToken; GET.Request(EndPoint); Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody); JSONDictionary = ExtractDictionary(JSONDictionary, "response"); if (JSONDictionary.ContainsKey("defaultSetType")) { BadgesAndSets.defaultSetType = JSONDictionary["defaultSetType"].ToString(); } foreach (KeyValuePair<string, object> Obj in (Dictionary<string, object>)JSONDictionary["badges"]) { BadgesAndSets.Badges.Add(new FourSquareBadge((Dictionary<string, object>)Obj.Value)); } foreach (object Obj in (object[])((Dictionary<string, object>)JSONDictionary["sets"])["groups"]) { BadgesAndSets.BadgeSets.Add(new FourSquareBadgeSet((Dictionary<string, object>)Obj)); } return BadgesAndSets; }