简体   繁体   English

使用 pastebin API 发出一个简单的 POST 请求

[英]Making a simple POST request with the pastebin API

I was wondering how I would be able to make a post request to pastebin.com.我想知道如何向 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 .他们有一个易于理解的API 文档,但是每当我运行一个简单的 POST 请求时,我总是收到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");

I hope it helps我希望它有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM