首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >的问题:错误的API请求

的问题:错误的API请求
EN

Stack Overflow用户
提问于 2022-05-03 01:57:14
回答 1查看 171关注 0票数 0

您知道,我一直在查看pastebin,我试图使用python发出post请求,结果是当api_dev_key正确时,我会收到错误的坏api请求,无效的dev_key。我甚至创建了另一个帐户来测试错误是否是共享的,而且它是共享的。

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

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-03 02:01:01

尝试将其更改为api_dev_key吗?

代码语言:javascript
复制
Post = PostPastebinAPI({
    "api_dev_key": "<YOUR API KEY HERE>",
    "api_option": "paste",
    "api_paste_code": "Test"
})
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72094113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档