1

我正在尝试使用 FourSquare API 使用以下 API 调用在纽约获取一些位置:

https://api.foursquare.com/v2/venues/search?ll=40.7,-74&limit=50

我不明白的是,如果调用限制为 50 个搜索结果(这是最大值),我怎样才能获得更多位置?使用 Facebook API 时,返回的结果是随机的,因此我可以发出多个调用以获得更多结果,但 FourSquare 似乎返回相同的结果集。有没有获得更多位置的好方法?

编辑:

行。所以有评论说我可能会违反合同协议,我不确定为什么会这样。我很乐意接受对此的推理。我的疑问是:假设我要搜索的位置不在返回的 50 个结果中?那样的话,不应该在某处有分页机制吗?

4

2 回答 2

2

这里的 API 文档可以提供帮助。

Foursquare 搜索与您提供的位置“点”(查询中的“将”参数)密切相关。简单的答案是,要在给定区域内查找更多场所,您只需使用该区域内的不同位置“点”再次查询即可。

两个查询,都在彼此靠近的点:

https://api.foursquare.com/v2/venues/search?ll=40.700,-74.000&limit=50
https://api.foursquare.com/v2/venues/search?ll=40.705,-74.005&limit=50

将为您提供两组不同的场地(可能重叠,具体取决于点的接近程度)。

The default intent for the search method is 'checkin', which will return the 50 most popular locations closest to that point. If instead you want to look at all the venues within an area, you can use the 'browse' intent. This takes either a 'radius' parameter, in which case it returns venues inside a circle around the given point with the given radius, or it takes two coordinates representing the 'sw' and 'ne' corners of a rectangle. So, you could do:

https://api.foursquare.com/v2/venues/search?ll=40.705,-74.005&limit=50&intent=browse&radius=50

which will give you 50 venues within the 50m circle around that point. A smaller radius will reduce the number of venues returned. So, by varying the radius and the point at which you search (or the size and position of the rectangle described by the 'sw' and 'ne' parameters), you can get more venues returned.

Hope that helps.

于 2011-11-17T10:00:04.260 回答
1

当前的 API 将结果限制为 50。您应该尝试将坐标更改为更精确,以避免找不到您的场地。

分页会很好,但 50 是很多搜索场所。

于 2011-09-08T21:14:51.717 回答