python Pastebin API问题:错误的API请求



你看,我一直在看pastebin api,我试图用python发出post请求,发生的情况是,我收到错误的api请求,无效的api_dev_key,当dev_key api是正确的。我甚至创建了另一个帐户来测试是否共享错误,结果是。

我看到有人有类似的错误,我通过将http更改为https来解决它,我尝试了它,但它仍然不起作用,这里是代码:

import requests
dev_key = "--The Dev Key"
url = "https://pastebin.com/api/api_post.php"
def PostPastebinAPI(args):
Lista_Errores = [
"Bad API request, invalid api_option",
"Bad API request, invalid api_dev_key",
"Bad API request, maximum number of 25 unlisted pastes for your free account",
"Bad API request, maximum number of 10 private pastes for your free account",
"Bad API request, api_paste_code was empty",
"Bad API request, maximum paste file size exceeded",
"Bad API request, invalid api_paste_expire_date",
"Bad API request, invalid api_paste_private",
"Bad API request, invalid api_paste_format",
"Bad API request, invalid api_user_key",
"Bad API request, invalid or expired api_user_key",
"Bad API request, you can't add paste to folder as guest"
]
response = requests.post(url, args)

for error in Lista_Errores:
if response.text == error:
return "Error en PastebinAPIPost: n" "{}".format(error)

return response.text

Post = PostPastebinAPI({
"dev_key_api": "2gpdDFVdUNeze0fSnB6b9-FZJ8g2tlYV",
"api_option": "paste",
"api_paste_code": "Test"
})
print(Post)

尝试更改为api_dev_key?

Post = PostPastebinAPI({
"api_dev_key": "<YOUR API KEY HERE>",
"api_option": "paste",
"api_paste_code": "Test"
})

最新更新