![](/img/trans.png)
[英]Python 3.5 / Pastebin "Bad API request, invalid api_option"
[英]Problem with python Pastebin API: Bad API request
你看,我一直在查看 pastebin api,並嘗試使用 python 發出發布請求,結果是當 dev_key api 正確時,我收到錯誤 Bad API request, invalid api_dev_key。 我什至創建了另一個帳戶來測試錯誤是否被分享,事實確實如此。
我看到有人有類似的錯誤,我把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"
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.