首页 > 解决方案 > Foursquare 用户详细信息端点返回 404 错误

问题描述

我正在尝试使用 Foursquare 用户详细信息端点来检索有关不同用户的信息,但由于某种原因,我收到 404 错误。我似乎无法找到此错误的原因,因此非常感谢任何帮助。这是我的用户“67786428”的代码,您可以在 Foursquare 上找到他们的页面:https ://foursquare.com/user/67786428 。

user_id = '67786428' 

url = 'https://api.foursquare.com/v2/users/{}?client_id={}&client_secret={}&v={}'.format(user_id, CLIENT_ID, CLIENT_SECRET, VERSION) # define URL

# send GET request
results = requests.get(url).json()
results

输出如下:

{'meta': {'code': 404,
  'errorType': 'endpoint_error',
  'errorDetail': 'Endpoint not found',
  'requestId': '5e13583c02a172001bbf17c7'},
 'response': {}}
  1. 我的 client_id 和 client_secret 正在工作,因为我正在使用场所端点获得结果。
  2. 我检查了我没有达到 API 调用的限制。
  3. 该代码以前可以工作,但我不确定 Foursquare 是否更改了他们的 API,现在必须以不同的方式构建 url,尽管根据文档,上述端点应该存在。

标签: python-3.xfoursquare

解决方案


您需要进行身份验证。 https://developer.foursquare.com/docs/api/configuration/authentication

试试下面的网址

https://api.foursquare.com/v2/users/{}?&oauth_token=(YOUR_TOKEN)

推荐阅读