Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/tools/api/post.js
2016-01-23 10:58:14 -05:00

44 lines
802 B
JavaScript

var http = require('http');
req = {
message: "test api",
frontend: "benis.tld",
name: "benisname",
subject: "ayyyyyy testing api",
/*
file: {
name: "benis.gif",
type: "image/gif",
data: // base64'd string here
},
*/
email: "sage",
ip: "8.8.8.8",
dubs: false,
// only include if we are replying to someone
reference: "<b7dee1453564515@benis.tld>",
newsgroup: "overchan.test"
}
j = JSON.stringify(req);
var r = http.request({
port: 8800,
method: "POST",
path: "/api/post",
auth: "user:pass",
headers: {
"Content-Type": "text/json",
"Content-Length": j.length
}
}, function (res) {
res.on('data', function (chunk) {
var r = chunk.toString();
var rj = JSON.parse(r);
console.log(rj.id);
});
});
r.write(j);
r.end();