如何使用Foursquare API获取所有场地数据 [英] How to get all the venues data using foursquare api
问题描述
我已经在foursquare中创建了应用,并获取了client_id和client_secret键.我需要一个城市的所有餐厅详细信息,但是我只有50个餐厅详细信息.请帮我 .预先感谢
I have created app in foursquare and get the client_id and client_secret key . I need all the restaurants details of a city.but i got only 50 restaurant details. Please help me . thanks in advance
'https://api.foursquare.com/v2/venues/explore?near=San Francisco,San Francisco§ion=food&novelty=50&client_id=client_id&client_secret=client_secret&v=20170109';
推荐答案
Matt是正确的,您可以使用offset
参数,但是他的链接文档和示例url有点差.
Matt is correct that you can use the offset
parameter but his linked documentation and sample url was a little off.
It looks like you're using the venues/explore endpoint, you can find documentation on this here: https://developer.foursquare.com/docs/venues/explore
要浏览结果,您可以设置以下内容:
To page through results you would set up something like this:
https://api.foursquare.com/v2/venues/explore?client_secret=****&client_id=****&v=20161101&limit=50&near=San Francisco, CA§ion=food
在响应(json)中,您应该检查json['response']['totalResults']
值以查看总共有多少结果.
In your response (json) you should inspect the json['response']['totalResults']
value to see how many results there are in total.
for (var i = 0; i < totalResults/50; i++) {
url = 'https://api.foursquare.com/v2/venues/explore?client_secret=****&client_id=****&v=20161101&limit=50&near=San Francisco, CA§ion=food&offset='(i + 1)*50';
}
看起来您正在使用的某些参数无效.
It also looks like some of the parameters that you're using are invalid.
- near参数应为
San Francisco, CA
而不是San Francisco, San Francisco
- 该API没有
novelty
参数,您是说要使用limit
吗?
- The near parameter should be
San Francisco, CA
notSan Francisco, San Francisco
- There is no
novelty
parameter with that API, do you mean to uselimit
?
这篇关于如何使用Foursquare API获取所有场地数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!