REST文档
---------------------------------------------------------------
curl --location --request POST 'https://zaya.io/api/v1/links' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {api_key}' \
--data-urlencode 'url={url}'
-----------------------------------------------------------------我的密码
import requests
api="https://zaya.io/api/v1/links"
API_KEY = "################################################"
data = "https://en.wikipedia.org/wiki/Python_(programming_language)"
headers = {'Authorization': 'Bearer ' + API_KEY}
r = requests.get(api, data=data, headers=headers)
print(response.text)我面对的错误是:
{"message":"You are not logged in.","status":403} 发布于 2022-04-20 13:49:28
文件要求您发送POST**.**
上
下面的代码运行良好,并进行了上述更正。
import requests
api = "https://zaya.io/api/v1/links"
# Never reveal your API key
API_KEY = "##########################################################"
# Data is URL Form encoded, so it must be key-value pair
data = {"url": "https://en.wikipedia.org/wiki/Python_(programming_language)"}
# Add proper headers
headers = {'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/x-www-form-urlencoded'}
# Most important. CURL says POST, you did GET
r = requests.post(api, data=data, headers=headers)
print(r.text)
# Gives proper responsehttps://stackoverflow.com/questions/71938692
复制相似问题