private static List<YelpResult> GenerateSchedule(string Location, string radius, bool isKidFriendly) { var o = GetOptions(); var y = new Yelp(o); string categoryList = ""; categoryList = setUpDefaultCategories(categoryList); categoryList = populateRemainingCategories(categoryList); var searchOptions = new YelpSharp.Data.Options.SearchOptions(); var categories = categoryList.Split(','); List<YelpResult> results = new List<YelpResult>(); foreach (var category in categories){ searchOptions.GeneralOptions = new GeneralOptions() { term = category }; searchOptions.LocationOptions = new LocationOptions() { location = Location, }; var serchResult = y.Search(searchOptions).businesses; //TODO: IF no search result gotta figure out what else to do... if (serchResult == null || serchResult.Count() == 0) continue; Random rnd = new Random(); int r = rnd.Next(0 , serchResult.Count - 1); serchResult.Remove(serchResult[r]); YelpResult yResult = new YelpResult(0, serchResult[r], serchResult); results.Add(yResult); } var retVals = insertDestinationsIntoTimeSlots(results); return retVals.OrderBy(f => f.Hour).ToList(); }
public void LocationWithCoordinates() { var o = GetOptions(); var yelp = new Yelp(o); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { term = "food" }, LocationOptions = new LocationOptions() { location = "bellevue", coordinates = new CoordinateOptions() { latitude = 37.788022, longitude = -122.399797 } } }; var results = yelp.Search(searchOptions); Console.WriteLine(results); }
public void SimpleTest() { string _term = "food"; string _location = "Denver"; var y = new Yelp(new Options() { ConsumerKey = _ConsumerKey, ConsumerSecret = _ConsumerSecret, AccessToken = _Token, AccessTokenSecret = _TokenSecret }); var searchOptions = new SearchOptions(); searchOptions.GeneralOptions = new GeneralOptions() { term = _term }; searchOptions.LocationOptions = new LocationOptions() { location = _location }; var results = y.Search(searchOptions); }
public void LocationWithCoordinates() { var yelp = new Yelp(Config.Options); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { term = "food" }, LocationOptions = new LocationOptions() { location = "bellevue", coordinates = new CoordinateOptions() { latitude = 37.788022, longitude = -122.399797 } } }; var results = yelp.Search(searchOptions).Result; Assert.IsTrue(results.businesses.Count > 0); }
public void LocationByBounds() { var yelp = new Yelp(Config.Options); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { LocationOptions = new CoordinateOptions() { latitude = 37.788022, longitude = -122.399797 } }; var results = yelp.Search(searchOptions).Result; Assert.IsTrue(results.businesses.Count > 0); }
public ListViewModel() { this.Businesses = new ObservableCollection<Business>(); this.SearchOptions = new SearchOptions() { //setting default search values for main page GeneralOptions = new GeneralOptions() { term = "body", category_filter = "tattoo", radius_filter = 25 * 1609.34 } }; }
public void LocationWithRadius() { var yelp = new Yelp(Config.Options); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { term = "food", radius_filter = 5 }, LocationOptions = new LocationOptions() { location = "bellevue" } }; var results = yelp.Search(searchOptions).Result; Assert.IsTrue(results.businesses.Count > 0); }
public void MultipleCategories() { var yelp = new Yelp(Config.Options); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { category_filter = "climbing,bowling" }, LocationOptions = new LocationOptions() { location = "Seattle" } }; var results = yelp.Search(searchOptions).Result; Assert.IsTrue(results.businesses.Count > 0); }
public void VerifyCoordinatesWithRadius() { var yelp = new Yelp(Config.Options); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { radius_filter = 3000 }, LocationOptions = new CoordinateOptions() { latitude = 47.603525, longitude = -122.329580 } }; var results = yelp.Search(searchOptions).Result; Assert.IsTrue(results.businesses.Count > 0); }
public void LocationWithRadius() { var o = GetOptions(); var yelp = new Yelp(o); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { term = "food", radius_filter = 5 }, LocationOptions = new LocationOptions() { location = "bellevue" } }; var results = yelp.Search(searchOptions); Console.WriteLine(results); }
public void MultipleCategories() { var o = GetOptions(); var yelp = new Yelp(o); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { category_filter = "climbing,bowling" }, LocationOptions = new LocationOptions() { location = "Seattle" } }; var results = yelp.Search(searchOptions); Console.WriteLine(results); }
public void AdvancedTest() { var y = new Yelp(Config.Options); var searchOptions = new SearchOptions(); searchOptions.GeneralOptions = new GeneralOptions() { term = "coffee" }; searchOptions.LocationOptions = new LocationOptions() { location = "seattle" }; var results = y.Search(searchOptions).Result; Assert.IsTrue(results.businesses != null); Assert.IsTrue(results.businesses.Count > 0); }
public void AdvancedTest() { var o = GetOptions(); var y = new Yelp(o); var searchOptions = new SearchOptions(); searchOptions.GeneralOptions = new GeneralOptions() { term = "coffee" }; searchOptions.LocationOptions = new LocationOptions() { location = "seattle" }; var results = y.Search(searchOptions); Console.WriteLine(results); }
public void LocationByCoordinates() { var o = GetOptions(); var yelp = new Yelp(o); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { radius_filter = 5 }, LocationOptions = new CoordinateOptions() { latitude = 37.788022, longitude = -122.399797 } }; var results = yelp.Search(searchOptions); Console.WriteLine(results); }
private void buttonSearch_Click(object sender, EventArgs e) { /* initiate duplicate checker with excel file */ if (xlWorkbook == null) { xlApp = new Excel.Application(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Excel Documents (*.xlsx)|*.xlsx"; ofd.ShowDialog(); xlWorkbook = xlApp.Workbooks.Open(ofd.FileName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorksheet = (Excel._Worksheet)xlWorkbook.Sheets[1]; } /* Save settings */ SaveSettings(); checkListCategories.Items.Clear(); statusBotStrip.Text = "Status: Searching"; string[] countriesArray = new string[]{"United States", "Singapore", "Australia", "New Zealand"}; if (searchCity.Lines.Length == 0) searchCity.Text = countriesArray[searchCountry.SelectedIndex]; for (int locationline = 0; locationline < searchCity.Lines.Length; locationline++) { for (int categoryline = 0; categoryline < searchCategory.Lines.Length; categoryline++) { if (searchGoogle.Checked) { /* Conduct first page search */ string searchCritera = generateSearchQuery(categoryline, locationline); statusBotStrip.Text = "Status: Searching " + searchCritera + " on Google"; searchCritera = searchCritera.Replace(" ", "+"); string json = getMapList(searchCritera); var jarray = JsonConvert.DeserializeObject<RootObjectPlaces>(json); if (jarray.status == "OK") { /* Populate the company list */ populateGoogleCompanies(jarray, xlWorksheet); /* Conduct next page search until reached end of search */ string nextPageToken = jarray.next_page_token; while (nextPageToken != null) { json = getMapList(searchCritera + "&pagetoken=" + nextPageToken); jarray = JsonConvert.DeserializeObject<RootObjectPlaces>(json); /* Populate again */ populateGoogleCompanies(jarray, xlWorksheet); nextPageToken = jarray.next_page_token; } } else if (jarray.status == "ZERO_RESULTS") textDebugger.AppendText("Google found no results searching:" + searchCritera + Environment.NewLine); else textDebugger.AppendText("Google Search Error: " + jarray.error_message + " when searching: " + searchCritera + Environment.NewLine); } saveDataSet(); if (searchYelp.Checked) { string searchCriteria = searchCategory.Lines[categoryline]; string search_Country = searchCountry.Text; string searchArea = ""; searchArea = generateSearchQueryArea(locationline); statusBotStrip.Text = "Status: Searching " + searchArea + " " + searchCriteria + " on Yelp"; var yelp = new Yelp(Config.Options); var searchOpt = new SearchOptions(); searchOpt.GeneralOptions = new GeneralOptions() { term = searchCriteria, radius_filter = 50000, category_filter = "homeservices", sort = 1 }; searchOpt.LocationOptions = new LocationOptions() { location = searchArea }; searchOpt.LocaleOptions = new LocaleOptions() { cc = search_Country }; var task = yelp.Search(searchOpt); int pages = (int)Math.Ceiling(task.Result.total / 20.0); for (int p = 1; p <= pages; p++) { for (int i = 0; i <= 19; i++) { try { Business business = task.Result.businesses[i]; string companyName = business.name; string companyAddress = String.Join(" ", business.location.address); string companyCity = business.location.city == null ? "" : business.location.city; string companyState = business.location.state_code == null ? "" : business.location.state_code; string companyZip = business.location.postal_code == null ? "" : business.location.postal_code; string companyCountry = business.location.country_code == null ? "" : business.location.country_code; string companyPhone = business.phone == null ? "" : fixPhoneNumberFormat(business.phone); if (!checkIfExistInCurrentList(companyName, companyPhone, "No website yet", "No email on 1st check")) { string companyWebsite = findYelpCompanyWebsite(task.Result.businesses[i].url); bool companyHasPicturesOrPersonalWebsite = true; if (companyWebsite == "No company website") { companyHasPicturesOrPersonalWebsite = doesYelpCompanyHavePictures(); companyWebsite = task.Result.businesses[i].url; } if (companyHasPicturesOrPersonalWebsite) { List<string> companyCategories = new List<string>(); foreach (string[] category in task.Result.businesses[i].categories) companyCategories.Add(category[0]); string companyHouzzSearch = generateHouzzSearchLink(replaceCompanyNamePTE(companyName), searchArea.Remove(0, searchArea.LastIndexOfAny(new char[] { ',', ' ' }) + 1).Replace(" ", ""), true); AddtoList(companyName, companyAddress, companyCity, companyState, companyZip, companyCountry, companyPhone, "No email", "", companyWebsite, companyHouzzSearch, companyCategories); } } } catch { } } var searchOptions = new SearchOptions(); searchOptions.GeneralOptions = new GeneralOptions() { term = searchCriteria, offset = (p * 20), radius_filter = 50000, category_filter = "homeservices", sort = 1 //distance }; searchOptions.LocationOptions = new LocationOptions() { location = searchArea }; searchOptions.LocaleOptions = new LocaleOptions() { cc = search_Country }; task = yelp.Search(searchOptions); } } saveDataSet(); if (searchFacebook.Checked) { string searchCriteria = searchCategory.Lines[categoryline]; string searchArea = generateSearchQueryArea(locationline); statusBotStrip.Text = "Status: Searching " + searchArea + " " + searchCriteria + " on Facebook"; string[] jsonFacebookSearchResults = new string[5]; jsonFacebookSearchResults[1] = getFacebookSearchList(searchCriteria, searchArea, "page", false); jsonFacebookSearchResults[2] = getFacebookSearchList(searchCriteria, searchArea, "page", true); jsonFacebookSearchResults[3] = getFacebookSearchList(searchCriteria, searchArea, "place", false); jsonFacebookSearchResults[4] = getFacebookSearchList(searchCriteria, searchArea, "place", true); for (int i = 1; i <= 4; i++) { var jarray = JsonConvert.DeserializeObject<RootObjectFacebook>(jsonFacebookSearchResults[i]); if( jarray.data != null & jarray.data.Count > 0 ) populateFacebookCompanies(jarray); else if( jarray.error != null) textDebugger.AppendText("Facebook search error: " + jarray.error.message + Environment.NewLine); } } saveDataSet(); if (searchYellowPages.Checked) { /* Conduct first page search */ string searchCriteria = searchCategory.Lines[categoryline].Replace(" ", "+"); string search_Country = searchCountry.Text; string searchArea = generateSearchQueryArea(locationline); statusBotStrip.Text = "Status: Searching " + searchArea + " " + searchCriteria + " on YellowPages"; for (int i = 1; i <= 30; i++) /* 30 pages even if they do not reach 30 */ { string json = getYPList(searchCriteria, searchArea, i); var jarray = JsonConvert.DeserializeObject<RootObjectYP>(json); if (jarray.searchResult.metaProperties.errorCode == "") { // Populate the company list if (jarray.searchResult.metaProperties.listingCount > 0) { populateYPCompanies(jarray, xlWorksheet); } else { textDebugger.AppendText("Error on YP page " + i.ToString() + ": No results found searching: " + searchArea + " " + searchCriteria + Environment.NewLine); break; } } else textDebugger.AppendText("Error on YP page " + i.ToString() + ": " + jarray.searchResult.metaProperties.message + Environment.NewLine); } } saveDataSet(); if( searchFactual.Checked ) { string searchCriteria = searchCategory.Lines[categoryline]; string search_Country = searchCountry.Text; string search_City = "", search_State = ""; Factual factual = new Factual(apiFactualKey, apiFactualSecret); Query q = new Query().SearchExact(searchCriteria); if (search_Country != "US") { q.And(q.Field("country").Equal(search_Country), q.Limit(50)); statusBotStrip.Text = "Status: Searching" + search_Country + " " + searchCriteria + " on Factual"; } if (search_Country == "US") { q.And(q.Field("country").Equal(search_Country), q.Field("region").Equal(search_State), q.Field("locality").Equal(search_City), q.Limit(50)); search_City = searchCity.Lines[locationline]; search_State = searchState.Text; statusBotStrip.Text = "Status: Searching " + search_Country + " " + search_City + " " + searchCriteria + " on Factual"; } /* if (searchCategoryFilters != "") q.Field("category_labels").Includes(searchCategoryFilters); */ int page = 1; try { var json = factual.Fetch("places", q); var jarray = JsonConvert.DeserializeObject<RootObjectFactual>(json); while (jarray.status == "ok" & jarray.response.data.Count > 0) { /* Populate the company list */ foreach (Datum item in jarray.response.data) { string companyName = item.name; string companyAddress = item.address == null ? "" : item.address; string companyCity = item.locality == null ? "" : item.locality; string companyState = item.region == null ? "" : item.region; string companyCountry = item.country == null ? "" : item.country; string companyZip = item.postcode == null ? "" : item.postcode; string companyPhone = item.tel == null ? "" : fixPhoneNumberFormat(item.tel); string companyEmail = item.email == null ? "no email" : item.email; string companyWebsite = item.website; string companyHouzzSearch = generateHouzzSearchLink(replaceCompanyNamePTE(companyName), companyState, true); List<string> companyCategories = item.category_labels == null ? new List<string>() : item.category_labels[0]; //textDebugger.AppendText(companyName + Environment.NewLine); AddtoList(companyName, companyAddress, companyCity, companyState, companyZip, companyCountry, companyPhone, companyEmail, "", companyWebsite, companyHouzzSearch, companyCategories); } page++; int pageOffset = (page - 1) * 50; Query qnew = new Query().SearchExact(searchCriteria); if ( searchCountry.Text == "US" || searchCountry.Text == "AU") { json = factual.Fetch("places", new Query() .SearchExact(searchCriteria) .Field("country").Equal(search_Country) .Field("region").Equal(search_State) .Field("locality").Equal(search_City) .Limit(50) .Offset(pageOffset)); } else if (searchCountry.Text != "US" & searchCountry.Text != "AU") { json = factual.Fetch("places", new Query() .SearchExact(searchCriteria) .Field("country").Equal(search_Country) .Limit(50) .Offset(pageOffset)); } jarray = JsonConvert.DeserializeObject<RootObjectFactual>(json); } } catch (FactualApiException ex) { textDebugger.AppendText("Factual Requested URL: " + ex.Url + Environment.NewLine); textDebugger.AppendText("Factual Error Status Code: " + ex.StatusCode + Environment.NewLine); ; textDebugger.AppendText("Factual Error Response Message: " + ex.Response + Environment.NewLine); ; if (ex.StatusCode.ToString().Contains("RequestedRangeNotSatisfiable")) textDebugger.AppendText("Factual reached end of results on page " + (page - 1).ToString() + Environment.NewLine); } } saveDataSet(); if( searchSensis.Checked ) { var searcher = new SsapiSearcher(searchEndPoint, apiSensisKey); // Perform a search and check the response var searchResponse = searcher.SearchFor(searchCategory.Text, searchCity.Text, searchState.Text, 1); /* page 1 */ if (searchResponse.code < 200 || searchResponse.code > 299) textDebugger.AppendText("Search failed - Error " + searchResponse.code + ": " + searchResponse.message + Environment.NewLine); else { textDebugger.AppendText("Total results found: " + searchResponse.totalResults.ToString() + Environment.NewLine); textDebugger.AppendText("Total pages: " + searchResponse.totalPages.ToString() + Environment.NewLine); for (int page = 1; page < searchResponse.totalPages; page++) { // Display the results foreach (var result in searchResponse.results) { string companyWebsite = getSensisContactComponents(result.primaryContacts, "URL"); if (companyWebsite != "") { string companyName = result.name; string companyAddress = "", companyCity = "", companyState = "", companyZip = ""; if (result.primaryAddress != null) { companyAddress = result.primaryAddress.addressLine == null ? "" : result.primaryAddress.addressLine; companyCity = result.primaryAddress.suburb == null ? "" : result.primaryAddress.suburb; companyState = result.primaryAddress.state == null ? "" : result.primaryAddress.state; companyZip = result.primaryAddress.postcode == null ? "" : result.primaryAddress.postcode; } string companyCountry = "AU"; string companyEmail = getSensisContactComponents(result.primaryContacts, "EMAIL"); string companyPhone = fixPhoneNumberFormat(getSensisContactComponents(result.primaryContacts, "PHONE")); if (companyPhone == "") companyPhone = fixPhoneNumberFormat(getSensisContactComponents(result.primaryContacts, "MOBILE")); string companyContactUs = companyEmail.Contains("@") ? "" : getSensisExternalLinksComponents(result.externalLinks, "Contact Us"); string companyHouzzSearch = generateHouzzSearchLink(replaceCompanyNamePTE(companyName), companyState, true); List<string> companyCategories = result.categories == null ? new List<string>() : new List<string>(new string[] { result.categories[0].name }); //textDebugger.AppendText(companyName + companyAddress + companyCity + companyState + companyZip + companyEmail + companyPhone + companyWebsite + Environment.NewLine); AddtoList(companyName, companyAddress, companyCity, companyState, companyZip, companyCountry, companyPhone, companyEmail, companyContactUs, companyWebsite, companyHouzzSearch, companyCategories); } } searchResponse = searcher.SearchFor(searchCategory.Text, searchCity.Text, searchState.Text, page); } } } /* At the end of each category, we save the data found into an xml file*/ saveDataSet(); } } statusBotStrip.Text = "Status: Done"; /* Save settings */ SaveSettings(); }
public void ErrorTest_INVALID_SIGNATURE() { var o = GetOptions(); var y = new Yelp(o); var searchOptions = new SearchOptions() { GeneralOptions = new GeneralOptions() { term = "coffee + tea" } }; var results = y.Search(searchOptions); Assert.IsTrue(results.error != null); Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.INVALID_SIGNATURE); Console.WriteLine(results); }
public void LimitTest() { var y = new Yelp(Config.Options); var searchOptions = new SearchOptions() { GeneralOptions = new GeneralOptions() { term = "coffee", limit = 15, }, LocationOptions = new LocationOptions() { location = "seattle, wa" } }; var results = y.Search(searchOptions).Result; if (results.error != null) { Assert.Fail(results.error.text); } if (results.businesses.Count != 15) { Assert.Fail(string.Format("Limit test returned {0} results instead of 15", results.businesses.Count)); } Console.WriteLine(results); }
public void MultipleCategories() { var o = GetOptions(); var yelp = new Yelp(o); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { category_filter="climbing,bowling" }, LocationOptions = new LocationOptions() { location = "Seattle" } }; var results = yelp.Search(searchOptions); Console.WriteLine(results); }
public void ErrorTest_UNSPECIFIED_LOCATION() { var y = new Yelp(Config.Options); var searchOptions = new SearchOptions(); var results = y.Search(searchOptions).Result; Assert.IsTrue(results.error != null); Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.UNSPECIFIED_LOCATION); Console.WriteLine(results); }
public void ErrorTest_UNAVAILABLE_FOR_LOCATION() { var y = new Yelp(Config.Options); var searchOptions = new SearchOptions() { LocationOptions = new CoordinateOptions() { latitude = 1, longitude = 1 } }; var results = y.Search(searchOptions).Result; Assert.IsTrue(results.error != null); Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.UNAVAILABLE_FOR_LOCATION); Console.WriteLine(results); }
/// <summary> /// advanced search based on search options object /// </summary> /// <param name="options"></param> /// <returns></returns> public SearchResults Search(SearchOptions options) { var raw = makeRequest("search", null, options.GetParameters()); var results = JsonConvert.DeserializeObject<SearchResults>(raw); return results; }
public void UrlEscapedCharacters() { var y = new Yelp(Config.Options); var searchOptions = new SearchOptions(); searchOptions.GeneralOptions = new GeneralOptions() { term = "coffee $&`:<>[]{}\"#%@/;=?\\^|~', tea" //term = "coffee $`:<>[]{}\"#%@/;=?\\^|~', tea" }; searchOptions.LocationOptions = new LocationOptions() { location = "seattle" }; var results = y.Search(searchOptions).Result; Assert.IsTrue(results.businesses != null); Assert.IsTrue(results.businesses.Count > 0); Console.WriteLine(results); }
public async Task<SearchResult> Search(SearchArea searchArea) { SearchError error = null; List<CoffeeShop> coffeeShops = new List<CoffeeShop>(); int numFound; int offset = 0; do { numFound = 0; SearchOptions query = new SearchOptions { GeneralOptions = new GeneralOptions { category_filter = "coffee", offset = offset, limit = 20, sort = 1, }, LocationOptions = new BoundOptions { sw_latitude = searchArea.SouthwestCorner.latitude, sw_longitude = searchArea.SouthwestCorner.longitude, ne_latitude = searchArea.NortheastCorner.latitude, ne_longitude = searchArea.NortheastCorner.longitude, }, }; Task<SearchResults> searchTask = this._yelp.Search(query); SearchResults results = await searchTask; if (results.error != null) { YelpSharp.Data.SearchError yelpError = results.error; error = new SearchError { Id = ErrorId.YelpError, Description = string.Format("ID: {0}; Description: {1}; Text: {2}; Field: {3}", yelpError.id, yelpError.description, yelpError.text, yelpError.field), }; } else if (results.total >= MaxSearchResults) { error = new SearchError { Id = ErrorId.TooManyResults, Description = string.Format("Maximum number of results exceeded, use a smaller region. Max Results: {0}", MaxSearchResults), }; } else { numFound = results.businesses.Count; IEnumerable<CoffeeShop> newShops = results.businesses .Where(b => b.location.city.IndexOf("seattle", StringComparison.OrdinalIgnoreCase) != -1) .Select(b => new CoffeeShop { Name = b.name, Location = new Coordinates { Latitude = b.location.coordinate.latitude, Longitude = b.location.coordinate.longitude, }, YelpId = b.id, }); coffeeShops.AddRange(newShops); offset += numFound; } } while (error == null && numFound > 0); return new SearchResult { Error = error, Results = coffeeShops, }; }
public void LocationWithRadius() { var o = GetOptions(); var yelp = new Yelp(o); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { term = "food", radius_filter=5 }, LocationOptions = new LocationOptions() { location = "bellevue" } }; var results = yelp.Search(searchOptions); Console.WriteLine(results); }
public void LocationByBounds() { var yelp = new Yelp(Config.Options); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { GeneralOptions = new GeneralOptions() { radius_filter = 5 }, LocationOptions = new CoordinateOptions() { latitude = 37.788022, longitude = -122.399797 } }; var results = yelp.Search(searchOptions).Result; Assert.IsTrue(results.businesses.Count > 0); }
public void LocationByCoordinates() { var yelp = new Yelp(Config.Options); var searchOptions = new YelpSharp.Data.Options.SearchOptions() { LocationOptions = new BoundOptions() { sw_latitude = 37.9, sw_longitude = -122.5, ne_latitude = 37.788022, ne_longitude = -122.399797 } }; var results = yelp.Search(searchOptions).Result; Assert.IsTrue(results.businesses.Count > 0); }
private static List<YelpResult> GetSingleDestinationOptions(string categoryList, string Location, string radius, bool isKidFriendly) { var o = GetOptions(); var y = new Yelp(o); var searchOptions = new YelpSharp.Data.Options.SearchOptions(); searchOptions.GeneralOptions = new GeneralOptions(){ term = categoryList }; searchOptions.LocationOptions = new LocationOptions(){ location = Location, }; var serchResults = y.Search(searchOptions).businesses; var retVal = new YelpResult(0, serchResults[0], serchResults); return new List<YelpResult> { retVal } ; }
public void VerifyTermWithEscapedCharacter() { var y = new Yelp(Config.Options); var searchOptions = new SearchOptions { GeneralOptions = new GeneralOptions { term = "Frimark Keller & Associates" }, LocationOptions = new LocationOptions { location = "60173" } }; var results = y.Search(searchOptions).Result; Assert.IsTrue(results.businesses != null); Assert.IsTrue(results.businesses.Count > 0); }
public GeoJson.PointLayer GetPointLayerByBounds(double neLat, double neLng, double swLat, double swLng, int page = 1, string[] ds = null, string[] tags = null) { //Consumer Key: kVvCwX0ocRhDHbA9LfdLrQ //Consumer Secret: RCJdVyZ5R3pVoc3hzyXIy-0ILQ0 //Token: ZgOH_PB5SkKIOIIeI3_9vYRE5ZNTZiIn //Token Secret: rSn8bgTH44an2XYJTgqQQqcDubs PointLayer layer = new PointLayer(this.DataSource); var options = new Options() { AccessToken = "ZgOH_PB5SkKIOIIeI3_9vYRE5ZNTZiIn", AccessTokenSecret = "rSn8bgTH44an2XYJTgqQQqcDubs", ConsumerKey = "kVvCwX0ocRhDHbA9LfdLrQ", ConsumerSecret = "RCJdVyZ5R3pVoc3hzyXIy-0ILQ0" }; Yelp yelp = new Yelp(options); SearchOptions searchOptions = new SearchOptions() { LocationOptions = new BoundOptions() { sw_latitude = swLat, sw_longitude = swLng, ne_latitude = neLat, ne_longitude = neLng } }; //VectorLocation vLocation = Util.VectorLocationFromBounds(neLat, neLng, swLat, swLng); //LocationOptions location = new LocationOptions(); //CoordinateOptions coords = new CoordinateOptions(); //coords.latitude = vLocation.Latitude; //coords.longitude = vLocation.Longitude; //location.coordinates = coords; //// location.location = coords; //searchOptions.LocationOptions = location; GeneralOptions generalOptions = new GeneralOptions(); //generalOptions.radius_filter = vLocation.Radius; generalOptions.limit = pageSize; if(page > 1) { generalOptions.offset = (page - 1) * pageSize; } searchOptions.GeneralOptions = generalOptions; SearchResults results = yelp.Search(searchOptions).Result; layer.TotalResults = results.total; layer.Page = page; layer.PageCount = layer.TotalResults % pageSize; layer.Points = PointsFromBusinessList(results.businesses); layer.PageSize = pageSize; return layer; }