Archived
1
0

add json api example

This commit is contained in:
Jeff Becker 2016-01-23 10:57:27 -05:00
parent 54fa915aeb
commit 110e607839
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B

42
contrib/tools/api/post.js Normal file
View File

@ -0,0 +1,42 @@
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,
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();