首页 > 解决方案 > Foursquare API 请求在版本参数上返回错误

问题描述

我正在尝试向 Foursquare 开发人员 API 发送一个获取请求,以通过“探索”功能获取所有附近场所的 json 响应。我读到的错误,

{'meta': {'code': 410,
  'errorType': 'param_error',
  'errorDetail': '**The Foursquare API no longer supports requests that pass in a version v <= 20120609.** For more details see https://developer.foursquare.com/overview/versioning',
  'requestId': '5d9f5d5fcad1b6002c61ef2c'},
 'response': {}}

我的输入代码如下:

LIMIT = 50
RADIUS = 16093.4
VERSION = 'YYYYMMDD'

url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format(CLIENT_ID, CLIENT_SECRET, latitude, longitude, VERSION, RADIUS, LIMIT)

results = requests.get(url).json() 

结果输出是我得到错误的地方。

我为 VERSION 变量尝试了多个不同的日期,例如 '20191008' 、 '20181008' 等,都给了我同样的错误。

标签: pythonpandasjupyter-notebookfoursquare

解决方案


您需要使用当前日期作为 YYYYMMDD 格式的 VERSION。在这种情况下,您需要将“YYYYMMDD”替换为当前日期。例如,今天的日期是 2021 年 3 月 24 日,因此您需要将“YYYYMMDD”替换为“20210324”。您还需要继续使用 Foursquare 并重置 CLIENT SECRET。


推荐阅读