forked from bouzuya/node-hatena-blog-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.js
More file actions
27 lines (22 loc) · 690 Bytes
/
Copy pathpost.js
File metadata and controls
27 lines (22 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const Blog = require('hatena-blog-api2').Blog;
const client = new Blog({
type: 'wsse',
userName: process.env.HATENA_USERNAME, // 'username'
blogId: process.env.HATENA_BLOG_ID, // 'blog id'
apiKey: process.env.HATENA_APIKEY // 'apikey'
});
//process.on('unhandledRejection', console.dir);
// POST CollectionURI (/<username>/<blog_id>/atom/entry)
client.postEntry({
title: 'テストエントリ',
updated:new Date(2010,1,1,10,10),
content: '# テストエントリ\r\nこれはテストです。\r\n\r\n',
categories:['blog','hatena']
})
.then(
// resolve
(res)=>{
console.log('#ポストの結果\n',JSON.stringify(res,null,1));
},
console.error
);