我发誓我能够使用这个 URL 结构通过特定的排序选项检索 Gists。
url = 'https://api.github.com/gists?sort=updated&direction=desc'
,但现在它一直在默认最近创建的情况下检索 Gists。
有什么变化吗?我在文档中找不到任何内容。看起来浏览器中的 URL 已更改,但修改我的代码也无济于事。
https://gist.github.com/Username?direction=desc&sort=updated
url = 'https://api.github.com/gists?direction=desc&sort=updated'
这是一个私人 GitHub 帐户,这是检索代码的其余部分,如果有关系,
# Headers for the request
headers = {'Authorization': f'Bearer {apiKey}'}
url = 'https://api.github.com/gists?sort=updated&direction=desc'
# Make a request to the URL to retrieve the Gists
response = requests.get(url, headers=headers)
data = response.json()
谢谢
可能是获取Gists的API端点变了,或者Gists排序的参数更新了。我建议查看 GitHub API 文档,看看 Gists API 是否有任何最近的更改或更新。
# Headers for the request
headers = {
'Authorization': f'Bearer {apiKey}',
'Accept': 'application/vnd.github.v3+json' # Specify the API version
}
url = 'https://api.github.com/gists?sort=updated&direction=desc'
# Make a request to the URL to retrieve the Gists
response = requests.get(url, headers=headers)
data = response.json()
此外,请确保您的 API 密钥具有访问 Gists 的必要权限。如果您仍然遇到问题,可以尝试联系 GitHub 支持以获得进一步帮助。