public FourSquareReponseClass(Dictionary<string, object> JSONDictionary) { JSON = JSONSerializer(JSONDictionary); Dictionary<string, object> Meta = ExtractDictionary(JSONDictionary, "meta"); MetaCode = GetDictionaryValue(Meta, "code"); MetaErrorType = GetDictionaryValue(Meta, "errorType"); if (MetaErrorType.Contains("deprecated")) { throw new Exception("deprecated Call"); //todo - handle this somehow. } MetaErrorDetail = GetDictionaryValue(Meta, "errorDetail"); if (JSONDictionary.ContainsKey("notifications")) { object oNotifications = JSONDictionary["notifications"]; foreach (object Obj in (List<object>)oNotifications) { FourSquareNotification Notification = new FourSquareNotification((Dictionary<string, object>)Obj); Notifications.Add(Notification); } } }
/// <summary> /// Allows you to check in to a place. /// </summary> /// <param name="venueId">The venue where the user is checking in. No venueid is needed if shouting or just providing a venue name.</param> /// <param name="venue">If are not shouting, but you don't have a venue ID or would rather prefer a 'venueless' checkin</param> /// <param name="shout">A message about your check-in. The maximum length of this field is 140 characters.</param> /// <param name="Broadcast">Required. How much to broadcast this check-in, ranging from private (off-the-grid) to public,facebook,twitter. Can also be just public or public,facebook, for example. If no valid value is found, the default is public. Shouts cannot be private.</param> /// <param name="LL">Latitude and longitude of the user's location. Only specify this field if you have a GPS or other device reported location for the user at the time of check-in.</param> public static FourSquareCheckin CheckinAdd(string VenueId, string Venue, string Shout, string Broadcast, string LL, string LLAcc, string Alt, string AltAcc, string AccessToken) { FourSquareCheckin CheckinResponse = new FourSquareCheckin(); Dictionary<string, string> parameters = new Dictionary<string, string>(); if (!Alt.Equals("")) { parameters.Add("alt", Alt); } if (!AltAcc.Equals("")) { parameters.Add("altAcc", AltAcc); } if (!Broadcast.Equals("")) { parameters.Add("broadcast", Broadcast); } if (!LL.Equals("")) { parameters.Add("ll", LL); } if (!LLAcc.Equals("")) { parameters.Add("llAcc", LLAcc); } if (!Shout.Equals("")) { parameters.Add("shout", Shout); } if (!Venue.Equals("")) { parameters.Add("venue", Venue); } if (!VenueId.Equals("")) { parameters.Add("venueId", VenueId); } parameters.Add("oauth_token", AccessToken); HTTPPost POST = new HTTPPost(new Uri("https://api.foursquare.com/v2/checkins/add"), parameters); Dictionary<string, object> JSONDictionary = JSONDeserializer(POST.ResponseBody); CheckinResponse = new FourSquareCheckin(ExtractDictionary(JSONDictionary, "response:checkin")); foreach (object Obj in (object[])JSONDictionary["notifications"]) { FourSquareNotification Notification = new FourSquareNotification((Dictionary<string, object>)Obj); CheckinResponse.notifications.Add(Notification); } return CheckinResponse; }