private static void PeekMessages(double latitude, double longitude, string peekId) { YikYakAPI api = new YikYakAPI(); try { var res = api.PeekMessages(latitude, longitude, peekId); var deserializerSettings = new JsonSerializerSettings() { DateFormatHandling = DateFormatHandling.IsoDateFormat, DateParseHandling = Newtonsoft.Json.DateParseHandling.None, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc }; JToken token = JsonConvert.DeserializeObject <JObject>(res, deserializerSettings); Console.WriteLine(string.Format("Total Results: {0}", token["messages"].Count())); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
private static void GetYaks(double latitude, double longitude) { YikYakAPI api = new YikYakAPI(); try { var res = api.GetYaks(latitude, longitude); Console.WriteLine(string.Format("Total Results: {0}", res.Count())); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
private static void GetLocations(double latitude, double longitude) { YikYakAPI api = new YikYakAPI(); try { int totalResults = 0; string fileName = string.Format(@"Locations_{0}.txt", DateTime.Now.ToString("MMddyyyyHHmmss")); FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter writer = new StreamWriter(stream); var res = api.GetFeaturedLocations(latitude, longitude); totalResults += res.Count; foreach (var item in res) { writer.Write(string.Format("{0}\t\t\t{1}\t\t\t\t{2},{3}\t\t{4}", item.PeekID, item.Name, item.Latitude, item.Longitude, item.Delta)); writer.WriteLine(); } res = api.GetOtherLocations(latitude, longitude); totalResults += res.Count; foreach (var item in res) { writer.Write(string.Format("{0}\t\t\t{1}\t\t\t\t{2},{3}\t\t{4}", item.PeekID, item.Name, item.Latitude, item.Longitude, item.Delta)); writer.WriteLine(); } writer.Close(); Console.WriteLine(string.Format("Total Results: {0}", totalResults)); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }