使用 pastebin API 发出一个简单的 POST 请求 [英] Making a simple POST request with the pastebin API
问题描述
我想知道如何向 pastebin.com 发出帖子请求.他们有一个易于理解的 API 文档,但是每当我运行一个简单的 POST 请求时,我总是得到 错误的 API 请求,无效的 api_option
.
I was wondering how I would be able to make a post request to pastebin.com. They have an easy to understand API documentation, but whenever I run a simple POST request I always get Bad API request, invalid api_option
.
我正在使用提出请求所需的最低限度,我不确定我做错了什么.
I'm using the bear minimum required to make the request, I'm not sure what I could be doing wrong.
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);request.send();request.response;
推荐答案
最后我把它变成了这样:
Finally I made it work like this:
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");
希望能帮到你
这篇关于使用 pastebin API 发出一个简单的 POST 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!