Multi-word searches with the Foursquare API
Posted December 10th, 2011
Share this:
When working on the first iteration of the FoursCrowd app, we encountered an odd situation. When searching for venues with multiple words, such as Jim’s Pizza, the API would return results only when searching for "Jim’s" or "Pizza", but not "Jim’s Pizza". The solution is simple; if a user searches for "Jim’s Pizza", you need to break up the query into single words separated with commas. In PHP, use this code:
$query = str_replace(" ", ",", $query);
This will break up the query into a format digestible by Foursquare. While easy to fix, it has the potential to irritate a lot of Foursquare app developers given the frequency of multi-word searches.
