python - 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' 等,都给了我同样的错误。
解决方案
您需要使用当前日期作为 YYYYMMDD 格式的 VERSION。在这种情况下,您需要将“YYYYMMDD”替换为当前日期。例如,今天的日期是 2021 年 3 月 24 日,因此您需要将“YYYYMMDD”替换为“20210324”。您还需要继续使用 Foursquare 并重置 CLIENT SECRET。
推荐阅读
- python - 从 C++ 访问在 python 中创建的 C++ 类
- python - 如何修复“TypeError:描述列表中的每个项目都必须是 AccessDescription”
- html - 输入 type=month 以另一种语言显示月份
- excel - 从excel中的数据透视表填充日志表
- vue.js - 在 VueJS/Quasar 应用程序上启动全屏
- excel - 使用 For 循环和 If/Then 语句的 VBA 脚本
- java - 在 Java Android 问题中从 HTTP (retrofit2) 响应下载 PDF 文件?
- wordpress - Wordpress:301 从本地主机重定向到域名
- mysql - Rails 中的悲观锁定 with_lock
- sql-server - 除非SSRS中每组有2行,否则如何隐藏行?