如何使用Foursquare API获取所有场地数据 [英] How to get all the venues data using foursquare api

查看:412
本文介绍了如何使用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&section=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&section=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&section=food&offset='(i + 1)*50';
}

看起来您正在使用的某些参数无效.

It also looks like some of the parameters that you're using are invalid.

  1. near参数应为San Francisco, CA而不是San Francisco, San Francisco
  2. 该API没有novelty参数,您是说要使用limit吗?
  1. The near parameter should be San Francisco, CA not San Francisco, San Francisco
  2. There is no novelty parameter with that API, do you mean to use limit?

这篇关于如何使用Foursquare API获取所有场地数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆