add json api example
This commit is contained in:
parent
54fa915aeb
commit
110e607839
42
contrib/tools/api/post.js
Normal file
42
contrib/tools/api/post.js
Normal 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();
|
Reference in New Issue
Block a user