社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

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

haytham • 3 年前 • 1567 次点击  

你看,我一直在看pastebin api,我试图用python发出post请求,结果是当开发密钥api正确时,我收到错误错误的api请求,无效的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)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/133496
文章 [ 1 ]  |  最新文章 3 年前