我想知道如何才能向 pastebin.com 发出发布请求。他们有一个易于理解的API documentation ,但是每当我运行一个简单的 POST 请求时,我总是得到 Bad API request, invalid api_option
。
我正在使用发出请求所需的最低限度,我不确定我可能做错了什么。
var request = new XMLHttpRequest;
request.open("POST", "https://pastebin.com/api/api_post.php?api_dev_key=mykey&api_option=paste&api_paste_code=hi", false);
请求.发送();
请求.响应;
最佳答案
最后我让它像这样工作:
var request = new XMLHttpRequest();
request.open("POST", "https://pastebin.com/api/api_post.php", true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send("api_dev_key=YOUR_KEY_HERE&api_option=paste&api_paste_private=0&api_paste_name=myname.js&api_paste_expire_date=10M&api_paste_format=javascript&api_paste_code=random");
希望对你有帮助
关于javascript - 使用 pastebin API 发出简单的 POST 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50430229/