public FourSquareTip(Dictionary<string, object> JSONDictionary) : base(JSONDictionary) { if (JSONDictionary.ContainsKey("response")) { JSONDictionary = ExtractDictionary(JSONDictionary, "response"); } JSONDictionary = ExtractDictionary(JSONDictionary, "tip"); id = GetDictionaryValue(JSONDictionary, "id"); text = GetDictionaryValue(JSONDictionary, "text"); createdAt = GetDictionaryValue(JSONDictionary, "createdAt"); status = GetDictionaryValue(JSONDictionary, "status"); url = GetDictionaryValue(JSONDictionary, "url"); if (JSONDictionary.ContainsKey("photo")) { //throw new Exception("To Do Item for this class"); //todo } if (JSONDictionary.ContainsKey("user")) { user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } if (JSONDictionary.ContainsKey("venue")) { venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]); } if (JSONDictionary.ContainsKey("todo")) { if ((GetDictionaryValue(ExtractDictionary(JSONDictionary, "todo"),"count")) != "") { todocount = Convert.ToInt16(GetDictionaryValue(ExtractDictionary(JSONDictionary, "todo"),"count")); } } if (JSONDictionary.ContainsKey("done")) { if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("groups")) { //throw new Exception("To Do Item for this class"); //todo } if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("friends")) { //throw new Exception("To Do Item for this class"); //todo } } }
/// <summary> /// Returns profile information for a given user, including selected badges and mayorships. /// </summary> /// <param name="USERID">Identity of the user to get details for. Pass self to get details of the acting user</param> public static FourSquareUser User(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 + "?callback=XXX&v=" + Version + "&oauth_token=" + AccessToken; GET.Request(EndPoint); Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody); FourSquareUser User = new FourSquareUser(JSONDictionary); return User; }
public FourSquareOverlaps(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); id = JSONDictionary["id"].ToString(); createdAt = JSONDictionary["createdAt"].ToString(); type = JSONDictionary["type"].ToString(); timeZone = JSONDictionary["timeZone"].ToString(); user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); }
public FourSquarePhoto(Dictionary<string, object> JSONDictionary) : base(JSONDictionary) { JSONDictionary = ExtractDictionary(JSONDictionary, "response:photo"); id = JSONDictionary["id"].ToString(); createdAt = JSONDictionary["createdAt"].ToString(); url = JSONDictionary["url"].ToString(); if (JSONDictionary.ContainsKey("sizes")) { foreach (object SizeObj in (GetDictionaryList(ExtractDictionary(JSONDictionary, "sizes"),"items"))) { sizes.Add(new FourSquarePhotoSize((Dictionary<string, object>)SizeObj)); } } if (JSONDictionary.ContainsKey("source")) { //todo } if (JSONDictionary.ContainsKey("user")) { user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } if (JSONDictionary.ContainsKey("venue")) { venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]); } if (JSONDictionary.ContainsKey("tip")) { //todo } if (JSONDictionary.ContainsKey("checkin")) { checkin = new FourSquareCheckin((Dictionary<string, object>)JSONDictionary["checkin"]); } }
public LeaderBoardItem(Dictionary<string, object> JSONDictionary) { Rank = Int32.Parse(JSONDictionary["rank"].ToString()); User = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); Score = new FourSquareScore((Dictionary<string, object>)JSONDictionary["scores"]); }
public FourSquareMayorship(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); Type = GetDictionaryValue(JSONDictionary, "type"); Checkins = GetDictionaryValue(JSONDictionary, "checkins"); DaysBehind = GetDictionaryValue(JSONDictionary, "daysBehind"); Message = GetDictionaryValue(JSONDictionary, "message"); ImageURL = GetDictionaryValue(JSONDictionary, "image"); if (JSONDictionary.ContainsKey("user")) { User = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } }
public FourSquareCheckin(Dictionary<string, object> JSONDictionary) : base(JSONDictionary) { JSONDictionary = ExtractDictionary(JSONDictionary, "response:checkin"); id = GetDictionaryValue(JSONDictionary, "id"); type = GetDictionaryValue(JSONDictionary, "type"); _private = GetDictionaryValue(JSONDictionary, "private"); if (JSONDictionary.ContainsKey("user")) { user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } timeZone = GetDictionaryValue(JSONDictionary, "timeZone"); if (JSONDictionary.ContainsKey("venue")) { venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]); } if (JSONDictionary.ContainsKey("location")) { location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]); } shout = GetDictionaryValue(JSONDictionary, "shout"); createdAt = GetDictionaryValue(JSONDictionary, "createdAt"); if (JSONDictionary.ContainsKey("source")) { source = new FourSquareSource((Dictionary<string, object>)JSONDictionary["source"]); } if (JSONDictionary.ContainsKey("photos")) { Dictionary<string, object> PhotoThings = (Dictionary<string, object>)JSONDictionary["photos"]; if (Int32.Parse(PhotoThings["count"].ToString()) > 0) { foreach (object PhotoObj in (GetDictionaryList( PhotoThings, "items"))) { photos.Add(new FourSquarePhoto((Dictionary<string, object>)PhotoObj)); } } } if (JSONDictionary.ContainsKey("comments")) { if ((GetDictionaryList( ExtractDictionary(JSONDictionary, "comments"),"items")).Count > 0) { foreach (object obj in (GetDictionaryList( ExtractDictionary(JSONDictionary, "comments"),"items"))) { comments.Add(new FourSquareComment((Dictionary<string, object>)obj)); } } } if (JSONDictionary.ContainsKey("overlaps")) { foreach (object obj in (GetDictionaryList(ExtractDictionary(JSONDictionary, "overlaps"),"items"))) { overlaps.Add(new FourSquareOverlaps((Dictionary<string, object>)obj)); } } if (JSONDictionary.ContainsKey("isMayor")) { if (JSONDictionary["isMayor"].ToString().Equals("True")) { IsMayor = true; } } }
public FourSquareComment(Dictionary<string, object> JSONDictionary) : base(JSONDictionary) { JSONDictionary = ExtractDictionary(JSONDictionary, "response:comment"); id = JSONDictionary["id"].ToString(); createdAt = JSONDictionary["createdAt"].ToString(); User = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); text = JSONDictionary["text"].ToString(); }
/// <summary> /// Sends a friend request to another user. /// </summary> /// <param name="USER_ID">required The user ID to which a request will be sent</param> public static FourSquareUser UserRequest(string USER_ID, string AccessToken) { Dictionary<string, string> Parameters = new Dictionary<string, string>(); Parameters.Add("callback", "XXX"); Parameters.Add("v", Version); Parameters.Add("oauth_token", AccessToken); HTTPPost POST = new HTTPPost(new Uri("https://api.foursquare.com/v2/users/" + USER_ID + "/request"), Parameters); Dictionary<string, object> JSONDictionary = JSONDeserializer(POST.ResponseBody); FourSquareUser User = new FourSquareUser(JSONDictionary); return User; }
/// <summary> /// Returns an array of a user's friends. /// </summary> /// <param name="USER_ID">Identity of the user to get friends of. Pass self to get friends of the acting user</param> /// <param name="Limit">Number of results to return, up to 500.</param> /// <param name="Offset">Used to page through results</param> public static List<FourSquareUser> UserFriends(string USER_ID, int Limit, int Offset, string AccessToken) { List<FourSquareUser> FriendUsers = new List<FourSquareUser>(); string Query = ""; if (Limit > 0) { if (Query.Equals("")) { Query = "?"; } else { Query += "&"; } Query += "Limit=" + Limit.ToString(); } if (Offset > 0) { if (Query.Equals("")) { Query = "?"; } else { Query += "&"; } Query += "Offset=" + Offset.ToString(); } if (Query.Equals("")) { Query = "?"; } else { Query += "&"; } HTTPGet GET = new HTTPGet(); string EndPoint = "https://api.foursquare.com/v2/users/" + USER_ID + "/friends" + Query + "oauth_token=" + AccessToken; GET.Request(EndPoint); Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody); Dictionary<string, object> ItemsDictionary = ExtractDictionary(JSONDictionary, "response:friends"); foreach (object obj in (object[])ItemsDictionary["items"]) { FourSquareUser FSU = new FourSquareUser((Dictionary<string, object>)obj); FriendUsers.Add(FSU); } return FriendUsers; }
public FourSquareTip(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); id = GetDictionaryValue(JSONDictionary, "id"); text = GetDictionaryValue(JSONDictionary, "text"); createdAt = GetDictionaryValue(JSONDictionary, "createdAt"); status = GetDictionaryValue(JSONDictionary, "status"); url = GetDictionaryValue(JSONDictionary, "url"); if (JSONDictionary.ContainsKey("photo")) { //throw new Exception("To Do Item for this class"); //todo } if (JSONDictionary.ContainsKey("user")) { user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } if (JSONDictionary.ContainsKey("venue")) { venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]); } if (JSONDictionary.ContainsKey("todo")) { if (((int)((Dictionary<string, object>)JSONDictionary["todo"])["count"]) > 0) { todocount = ((int)((Dictionary<string, object>)JSONDictionary["todo"])["count"]); } } if (JSONDictionary.ContainsKey("done")) { if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("groups")) { throw new Exception("To Do Item for this class"); } if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("friends")) { throw new Exception("To Do Item for this class"); } } }
public FourSquareComment(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); id = JSONDictionary["id"].ToString(); createdAt = JSONDictionary["createdAt"].ToString(); User = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); text = JSONDictionary["text"].ToString(); }
public FourSquareCheckin(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); id = GetDictionaryValue(JSONDictionary, "id"); type = GetDictionaryValue(JSONDictionary, "type"); _private = GetDictionaryValue(JSONDictionary, "private"); if (JSONDictionary.ContainsKey("user")) { user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]); } timeZone = GetDictionaryValue(JSONDictionary, "timeZone"); if (JSONDictionary.ContainsKey("venue")) { venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]); } if (JSONDictionary.ContainsKey("location")) { location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]); } shout = GetDictionaryValue(JSONDictionary, "shout"); createdAt = GetDictionaryValue(JSONDictionary, "createdAt"); if (JSONDictionary.ContainsKey("source")) { source = new FourSquareSource((Dictionary<string, object>)JSONDictionary["source"]); } if (JSONDictionary.ContainsKey("photos")) { Dictionary<string, object> PhotoThings = (Dictionary<string, object>)JSONDictionary["photos"]; if (Int32.Parse(PhotoThings["count"].ToString()) > 0) { foreach (object obj in (object[])PhotoThings["items"]) { //TODO: Photos as an object throw new Exception("Photos here!"); } } } if (JSONDictionary.ContainsKey("comments")) { if (((object[])ExtractDictionary(JSONDictionary, "comments")["items"]).Length > 0) { foreach (object obj in ((object[])ExtractDictionary(JSONDictionary, "comments")["items"])) { comments.Add(new FourSquareComment((Dictionary<string, object>)obj)); } } } if (JSONDictionary.ContainsKey("overlaps")) { foreach (object obj in ((object[])ExtractDictionary(JSONDictionary, "overlaps")["items"])) { overlaps.Add(new FourSquareOverlaps((Dictionary<string, object>)obj)); } } if (JSONDictionary.ContainsKey("isMayor")) { if (JSONDictionary["isMayor"].ToString().Equals("True")) { IsMayor = true; } } }