obtaining foursquare venue id - ios

i am doing some work for an iphone app that retrieves a bunch venues from a webservice, kinda like Yelp. They also want to be able to checkin to one such venue with Foursquare. Is it reasonable to demand that they also return a foursquare venue id, or do i have to look it up given a lat long? My concern is that even if i have a lat long, i dont necessarily know if the venue i looked up is the correct one. Do people just live with this uncertainty, or what? I should also elaborate that the UI is set up so that only one venue gets shown in the checkin UI. Maybe the solution is to provide multiple venues? Ideas? Opinions? Thanks!

If your other webservice offers Foursquare IDs, then getting them there will be your easiest solution. If not, you have two options:
Foursquare provides a location service that you could use to retrieve a list of nearby venues (https://developer.foursquare.com/venues/). That would give you a list of names, categories, addresses, and foursquare ids.
From there, you could search on your other webservice using name and address as needed and have the foursquare id straight from the source.
You can pass the search endpoint (https://developer.foursquare.com/docs/venues/search.html) a location and query string, then iterate over the results to see if you received a direct match.
This system is less precise than (1) (so, yes, you'll have to live with the uncertainty that a venue from your other service might not appear on foursquare, or might be at a slightly-incorrect location), but it will likely work in most situations.

I deal with this for my startup. Unfortunately, there's no good solution.
I have a batch job that given the lat/long and name, it searches the Foursquare API for any venue with the same name & within 0.1 miles. More than 5 times out of 10, the name will be different or there will be multiple venues with the same name. We had to manually set the Foursquare Id.

Related

Best way to get user's country?

I'm about to start expanding my secondhand app, where people can put their used university books for sale.
Right now the app is only available in one country, but in the near future other scandinavian countries will follow.
As an example I want to expand to Sweden, the user should only be able to see/buy/sell books that are for sale in that country.
I have come up with 2 solutions, but none of them are quite good:
Location decides country.
User selects the country from a list.
I would like to hear your thoughts on this, since lots of apps do this - but I can't figure out how.
Why not a combination of both? Try the location services first, if for whatever reason they have location services turned off or don't allow it, have them select their country. The country selection should be one of the first prompts they are given when they open the app (if location services aren't on). Otherwise, before they are allowed to post any books for sale. In other words they shouldn't be allowed to put a book up for sales without the app knowing which country they are in.
Are you using swift (what version) or objective-c?
https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/
You'll need a list of countries: How do I get a list of countries in Swift ios?
If you are willing to pay some. You could look at a ip based Solution like the www.maxmind.com api. It Gives country info and more. And we bought 50.000 queries for 50 dollars. And as we check once per user, we did not even finísh our bought queries!
I believe your application should do a guesswork and provide easy-to-use alternative for the case when the guess was incorrect. Get the country by location or IP. When the user installs the app, show the selected country and make sure your user can easily change it both in the installer and in the app itself (if, for instance, one student moves from a country to the other).

How can I create custom trips via Google Maps API in Rails and then store them?

I'm making a web application in Rails 4 that is going to allow users to create trips. These trips are going to be built dynamically using Google Maps API based upon user input. IE, users can create different waypoints and locations that they visited. I want users to be able to add waypoints and descriptions about particular stops.
But I want these locations to be stored so that there's a search function where users can search for different regions such as around a particular address or state.
I'm not looking for anything overly specific here, I just want an idea of how to set it up.
What I've thought of so far is that Users create trips which have many waypoints that in turn are models. I'm not sure that is ideal however.
Thoughts? Even a link to a post I might have missed is helpful. Thanks.
Edit: In case anyone runs across this problem in the future. I went with Google Map's Directions API. It lets you pass in waypoints as an array of objects. I used JavaScript to add waypoints as necessary and then allowed the user to submit to how the map looked. Then, if they liked it, they submitted the trip form which logged the input values into the db as attributes to the trip object.

globally unique location id

I'm trying to find a good way to store and connect users based upon their city.
Location names can come from a variety of places, including facebook connection, ip lookup, and event user input.
I want to be able to input an address and get back a unique location ID. NY and New York will be understood as the same, but cities in two locations are not understood as the same.
Can I use facebook's location databse for this? Or google's location api? Or would it be better to roll my own, doing searches and filtering to consecutively narrow down results, from country to state to city, while normalizing for abbreviations, internationalizations, and typos? Or is there a plugin that will do this for me?
Thanks!
I would use https://github.com/alexreisner/geocoder . In general you have to add latitude and longitude to your model (they will identify location) and then specify which field should be geocoded. It allows you to store locations from different sources: city name, ip address and others. There are many configuration options (eg. you can specify Geocoding Services). Check out the gem readme page for all the details.

Amazon Product API - How to get items for sale by price?

I have a strage requirement from a client, he needs to display a ramdom selection (100 - 200 items from mixed categories) of products for sale on & shipped by Amazon but ordered by price. The idea is to allow people find gift ideas based a user input price point.
I have been looking through the API docs but cannot see an obvious way to find search by price, I am thinking of writing a script to "copy" large parts of the amazon product catalogue into a local database & have it update every few weeks, then use this for user searches, but this does not feel right / their must be a better way.
Has anyone any experience with this type of problem? Thanks!
You would want to use the Amazon Product Advertising API. Using this API you would want to perform a SearchIndex-ItemSearch query. Possible parameters to ItemSearch are available on the API Docs here
You can see in the docs that you cannot query by MinimumPrice and MaximumPrice on SearchIndex: All. However, if you search specific indexes, it allows you to do a price related search.
I would guess that you can agree with your client which categories should the items be from. Then you can just query them one by one.
Amazon's database changes very often. Hence, caching data for a week without updating may not be desirable.

City/Country text field validation

I need to keep track of the users lat/lng/city/country for my application with the following two requirements:
1) Get the users lat/lng/city/country automatically. (This is easy, I can use the ip or if they have a browser that supports geolocation, even better).
2) The user is allowed to customize this location (maybe the ip address lookup didn't give an accurate city). The location is a freeform text field (not a dropdown). When the user enters a new location it should be validated against available cities/countries. If it validates against any one of them, select it and then retrieve the latlng for the new location. (This is what I'm having trouble with)
Also to clarify, this is a Rails 3 app using MongoDB. I am looking for either a single API or database that would allow me to do both (1) and (2). Has anyone done anything similar? Looking for some ideas as to how others have done this.
Your question isn't entirely clear as to what problem you are having. In general terms, I would do it like this:
have a Location model that stores location name and coordinates
when the user enters a location, send an Ajax request to look it up
if it's found, set the location in the session
if it isn't found, return a list of similarly named locations (in case there was a typo) and let the user choose one or stick to their input
when they are done with the input, insert a new location if required and store User.location_id.
You could use Google's Geocoding API to look up the coordinates of unknown locations.
I would recommend the Geokit Gem, it does a very nice job of providing a front end for several Geocoding APIs. I highly recommend sticking with Yahoo or Google, just for sheer data integrity issues.
There is a rails plugin, that adds some nice helpers to Activerecord. At the moment the main project is not rails 3 compatible, but there is at least one fork that has updated for rails 3.

Resources