public static void QueryAPIAndPrintResult(string term, double latitude, double longitude) { var client = new YelpAPIClient(); JObject response = client.Search(term, latitude, longitude); JArray businesses = (JArray)response.GetValue("businesses"); if (businesses.Count == 0) { //Console.WriteLine("No businesses for {0} in {1} found.", term, location); return; } string business_id = (string)businesses[0]["id"]; Console.WriteLine( "{0} businesses found, querying business info for the top result \"{1}\"...", businesses.Count, business_id ); response = client.GetBusiness(business_id); Console.WriteLine(String.Format("Result for business {0} found:", business_id)); Console.WriteLine(response.ToString()); }
internal bool MailJetMessage(string toMail, string business, string message) { string APIKey = "633afd3eb0cf804cdb516339f60daca3"; string SecretKey = "e70e0805566054df533c996b3f67b96b"; YelpAPIClient yelpClient = new YelpAPIClient(); var buisness = yelpClient.GetBusiness(business); try { using (var client = new WebClient()) { var values = new NameValueCollection(); values["from"] = "*****@*****.**"; values["to"] = toMail; values["subject"] = "Let's go to " + buisness.GetValue("name") + "!"; values["text"] = "Let's go to " + buisness.GetValue("name") + "\n\n" + message + "\n\n" + buisness.GetValue("url"); NetworkCredential myCreds = new NetworkCredential(APIKey, SecretKey); client.Credentials = myCreds; var response = client.UploadValues("http://api.mailjet.com/v3/send/message", values); var responseString = Encoding.Default.GetString(response); } return(true); } catch { return(false); } }
public bool MailJetSuggest(string toMail, string fromMail, string business) { string APIKey = "633afd3eb0cf804cdb516339f60daca3"; string SecretKey = "e70e0805566054df533c996b3f67b96b"; string from = fromMail; string to = toMail; YelpAPIClient yelpClient = new YelpAPIClient(); var buisness = yelpClient.GetBusiness(business); try { using (var client = new WebClient()) { var values = new NameValueCollection(); values["from"] = "*****@*****.**"; values["to"] = toMail; int hour = System.DateTime.Now.Hour; string meal = "a meal"; if (hour < 11) { meal = "breakfast"; } else if (hour < 15) { meal = "lunch"; } else { meal = "dinner"; } values["subject"] = "Melissa was thinking of you!"; values["text"] = "Melissa is currently at " + buisness.GetValue("name") + "\nAnd thinks that you would enjoy it!\n" + buisness.GetValue("url"); NetworkCredential myCreds = new NetworkCredential(APIKey, SecretKey); client.Credentials = myCreds; var response = client.UploadValues("http://api.mailjet.com/v3/send/message", values); var responseString = Encoding.Default.GetString(response); } return(true); } catch { return(false); } }
public bool twillioRec(string fromNum, string toNum, string business) { try { YelpAPIClient yelpClient = new YelpAPIClient(); var buisness = yelpClient.GetBusiness(business); var buisnessURl = buisness.GetValue("url"); string AccountSid = "ACcdeba5687e73b2f0018fe8b7004e6fc8"; string AuthToken = "1e389c71315f88b00945ed9499dea847"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var message = twilio.SendMessage("+15714512210", "+1" + toNum, "Your friend thinks you would like this restaurant " + buisnessURl); return(true); } catch { return(false); } }
public JObject GetBusiness(string business) { YelpAPIClient client = new YelpAPIClient(); return(client.GetBusiness(business)); }
// GET: API public JObject NearbyRestaurants(double latitude, double longitude) { YelpAPIClient client = new YelpAPIClient(); return(client.Search("food", latitude, longitude)); }