drevls8138 2012-05-26 19:01
浏览 16

省略搜索结果

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?

  • 写回答

1条回答 默认 最新

  • dongxing1960 2012-05-27 07:34
    关注

    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)
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类