0

using foursquare api php

I am performing a search for venues with nightlife categories:

$params = array("near"=>"92101", "radius"=>"800", "intent"=>"checkin",
                "categoryId"=>"4d4b7105d754a06376d81259", "limit"=>"50");

$venues = $foursquare->GetPublic("venues/search", $params);

works as expected...kind of. the problem is restaurants that have been sub categorized as bars are filling up my return limit. so in that search i may only get a few actual nightlife venues. it would be very helpful if i could omit venues that have certain categories. get 50 nightlife venues but not the ones also labeled as food.

i have searched around and keep re-reading the search endpoint page hoping i overlooked the omit feature. any help?

betabandido
  • 18,946
  • 11
  • 62
  • 76
Zach J
  • 23
  • 4

1 Answers1

0

We have had the same problem (different category types)

What we ended up doing is performing several searches with specific categories. The categoryId field accepts multiple comma delimited categories, so we executed sometimes up to 3 searches with multiple categoryIds.

So in stand of asking for a single category, your request would look like (no 'bars', i just picked a couple of random nightlife categories):

$params = array("near"=>"92101", "radius"=>"800", "intent"=>"checkin",
                "categoryId"=>"4bf58dd8d48988d11f941735,4bf58dd8d48988d121941735,...", "limit"=>"50");

And then do another request with the general nightlife

$params = array("near"=>"92101", "radius"=>"800", "intent"=>"checkin",
                "categoryId"=>"4d4b7105d754a06376d81259", "limit"=>"50");

And merge the results.

Two things to note with this solution:

  1. You may (probably) get overlapping results from multiple searches, as venues sometimes have more than one category (as you found out already), remember to handle the multiple results. We first scanned all the results and kept on the unique ones according to the foursquare ID, then started our processing.
  2. This solution does not scale well with the foursquare API - doing 40 searches will not work.. (but there is no other way of getting what you need without it, so I am still writing the entire solution here)
Jonathan Levison
  • 2,617
  • 1
  • 18
  • 22
  • Sajid from foursquare here -- Jonathan is right. We don't currently offer negative filters on our venues search endpoint. You can try doing multiple searches like Jonathan suggested, and filter out the ones with the categories you don't want client-side. – smehmood May 29 '12 at 19:00