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

45 lines
803 B
JavaScript
Raw Normal View History

2016-01-23 20:57:27 +05:00
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,
2016-01-23 21:06:59 +05:00
newsgroup: "overchan.test",
2016-01-23 20:58:14 +05:00
// only include if we are replying to someone
2016-01-23 21:06:59 +05:00
reference: "<b7dee1453564515@benis.tld>"
2016-01-23 20:57:27 +05:00
}
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();