Skip to content

saltfactory/node-tistory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

node-tistory

node-tistory๋Š” Tistory์˜ ์˜คํ”ˆ API๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ Node.js ๋ชจ๋“ˆ์ด๋‹ค.

Install global module

node-tistory๋Š” global๋กœ ์„ค์น˜ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด npm install -g๋กœ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค.

npm install -g node-tistory

๊ธ€๋กœ๋ฒŒ ์„ค์น˜ํ•œ ํ›„ tistory ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

tistory -help

Install local module

npm install node-tistory

local module๋กœ ์„ค์น˜ํ•  ๊ฒฝ์šฐ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

var Tistory = require('node-tistory');

Global configuration file

node-tistory๋Š” $HOME/.tistory.json ํŒŒ์ผ์„ ๊ธ€๋กœ๋ฒŒ ์„ค์ • ํŒŒ์ผ๋กœ ์ฝ์–ด๋“ค์ธ๋‹ค. node-tistory๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ํ•„์š”ํ•œ ์˜ต์…˜์ •๋ณด๋ฅผ .tistory.json์— ๋ฏธ๋ฆฌ ์ €์žฅํ•ด๋‘๋ฉด ํ•ญ์ƒ ์ด ์„ค์ • ํŒŒ์ผ์„ ๋จผ์ € ์ฝ์–ด์„œ ์˜ต์…˜์ •๋ณด๋กœ ์„ค์ •ํ•œ๋‹ค.

echo '{
    "targetUrl": "Tistory URL",
    "access_token": "Tistory API access_token",
    "output": "json"
}' > ~/.tistory.json

Tistory API

Tistory์—์„œ ์ œ๊ณตํ•˜๊ณ  ์žˆ๋Š” ์˜คํ”ˆ API ๊ฐ€์ด๋“œ ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉด ๋œ๋‹ค.

node-tistory API interface

node-tistory ์—์„œ๋Š” Tistory์˜ ์˜คํ”ˆ API๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ฉ”์†Œ๋“œ ํ˜•ํƒœ์˜ interface๋ฅผ ์ œ๊ณตํ•˜๊ณ  ์žˆ๋‹ค.

๋ชจ๋“ˆ ์ธํ„ฐํŽ˜์ด์Šค Tistory API ์„ค๋ช…
blog info /apis/blog/info ๋ธ”๋กœ๊ทธ ์ •๋ณด
post list /apis/post/list ๊ธ€ ๋ชฉ๋ก
read /apis/post/read ๊ธ€ ๋ณด๊ธฐ
write /apis/post/write ๊ธ€ ์“ฐ๊ธฐ
modify /apis/post/modify ๊ธ€ ์ˆ˜์ •
attach /apis/post/attach ํŒŒ์ผ์ฒจ๋ถ€
category list /apis/category/list ๋ถ„๋ฅ˜ ๋ชฉ๋ก
find ๋ถ„๋ฅ˜ ๊ฒ€์ƒ‰

๋ชจ๋“  interface ๋ฉ”์†Œ๋“œ๋Š” params, callback์„ ์ธ์ž๊ฐ’์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. params๋Š” Object ํ˜•ํƒœ์ด๊ณ  callback์€ err,body,res ๊ฐ’์„ ๋ฐ›๋Š” ํ•จ์ˆ˜ ํ˜•ํƒœ์ด๋‹ค. params์˜ key๋Š” Tistory ์˜คํ”ˆ API์˜ Request Parameter์˜ ์ด๋ฆ„๊ณผ ๋™์ผํ•˜๋‹ค.

e.g. ํ‹ฐ์Šคํ† ๋ฆฌ ๋ธ”๋กœ๊ทธ http://blog.saltfactory.net ์ •๋ณด ๋ณด๊ธฐ

var params = {
  targetUrl:'blog.satlfactory.net'
};

var callback = function(err, body, res){
  console.log(body);
};

tistory.blog.info(params, callback);

e.g. http://blog.saltfactory.net์˜ ๊ธ€ ๋ชฉ๋ก๋ณด๊ธฐ

var params = {
  page: 1,
  count: 10
};

tistory.post.list(params, function(err, body, res){
  console.log(body);
});

node-tistory interface parameters

node-tistory์˜ ์ธํ„ฐํŽ˜์ด์Šค์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” Object ํ˜•ํƒœ๋กœ ์ง€์ •ํ•œ๋‹ค.

var params = {
  'targetUrl':'blog.saltfactory.net'
};

tistory.blog.info (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String http://saltfactory.tistory.com ๊ณผ ๊ฐ™์ด 1์ฐจ ๋„๋ฉ”์ธ ๊ฒฝ์šฐ saltfactory, http://blog.saltfactory.net ๊ณผ ๊ฐ™์ด 2์ฐจ ๋„๋ฉ”์ธ์ผ ๊ฒฝ์šฐ blog.saltfactory.net ํ•„์ˆ˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜
์—†์Œ ์—†์Œ ํŒŒ๋ผ๋ฏธํ„ฐ ์—†์ด ์ฝœ๋ฐฑํ•จ์ˆ˜๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์—†์Œ

tistory.post.list (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String ๋ธ”๋กœ๊ทธ URL ํ•„์ˆ˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜
page Number ํ•ด๋‹น ํŽ˜์ด์ง€ ๊ธ€ ๋ชฉ๋ก, ๊ธฐ๋ณธ๊ฐ’ 1 ์˜ต์…˜
count 1~30 ํŽ˜์ด์ง€๋‹น ๊ธ€ ๊ฐฏ์ˆ˜, ๊ธฐ๋ณธ๊ฐ’ 10 ์˜ต์…˜
categoryId Number ๋ถ„๋ฅ˜์— ํ•ด๋‹นํ•˜๋Š” ๊ธ€ ๋ชฉ๋ก, ๊ธฐ๋ณธ๊ฐ’ ์ „์ฒด ์˜ต์…˜
sort 'id' or 'date' 'id'๋Š” ๊ธ€๋ฒˆํ˜ธ, 'date'๋Š” ์ž‘์„ฑ๋‚ ์งœ, ๊ธฐ๋ณธ๊ฐ’ id ์˜ต์…˜

tistory.post.read (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String ๋ธ”๋กœ๊ทธ URL ํ•„์ˆ˜
postId Number ๊ธ€ ๋ฒˆํ˜ธ ํ•„์ˆ˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜

tistory.post.write (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String ๋ธ”๋กœ๊ทธ URL ํ•„์ˆ˜
title String ๊ธ€ ์ œ๋ชฉ ํ•„์ˆ˜
content String ๊ธ€ ๋‚ด์šฉ ์˜ต์…˜
visibility 0,1,2,3 0:๋น„๊ณต๊ฐœ, 1:๋ณดํ˜ธ, 2:๊ณต๊ฐœ, 3:๋ฐœํ–‰, ์ƒ๋žต์‹œ 0 ์˜ต์…˜
published String UNIX_TIMESTAMP() ์˜ˆ์•ฝ๋ฐœ์†ก ์˜ต์…˜
tag String ,๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ๊ฐœ ํƒœ๊ทธ ๋ฌธ์ž์—ด ์˜ต์…˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜

tistory.post.modify (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String ๋ธ”๋กœ๊ทธ URL ํ•„์ˆ˜
postId Number ์ˆ˜์ •ํ•  ๊ธ€ ๋ฒˆํ˜ธ ํ•„์ˆ˜
title String ๊ธ€ ์ œ๋ชฉ ํ•„์ˆ˜
content String ๊ธ€ ๋‚ด์šฉ ์˜ต์…˜
visibility 0,1,2,3 0:๋น„๊ณต๊ฐœ, 1:๋ณดํ˜ธ, 2:๊ณต๊ฐœ, 3:๋ฐœํ–‰, ์ƒ๋žต์‹œ 0 ์˜ต์…˜
published String UNIX_TIMESTAMP() ์˜ˆ์•ฝ๋ฐœ์†ก ์˜ต์…˜
tag String ,๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ๊ฐœ ํƒœ๊ทธ ๋ฌธ์ž์—ด ์˜ต์…˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜

tistory.post.attach (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String ๋ธ”๋กœ๊ทธ URL ํ•„์ˆ˜
uploadedfile String ํŒŒ์ผ๊ฒฝ๋กœ ํ•„์ˆ˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜

tistory.category.list (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String ๋ธ”๋กœ๊ทธ URL ํ•„์ˆ˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜

tistory.category.find (params, callback)

params ๊ฐ’ ์„ค๋ช… ํ•„์š”
access_token String OAuth 2.0 ์ธ์ฆ ํ›„ ํš๋“ํ•œ access_token ํ•„์ˆ˜
targetUrl String ๋ธ”๋กœ๊ทธ URL ํ•„์ˆ˜
name String ๋ถ„๋ฅ˜๋ช… ํ•„์ˆ˜
output 'json','xml' ๊ธฐ๋ณธ๊ฐ’ 'json' ์˜ต์…˜

Tistory์˜ ๋ชจ๋“  API๋Š” access_token, targetUrl ๊ทธ๋ฆฌ๊ณ  output ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— node-tistory์˜ global configuration file์ธ $HOME/.tistory.json์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ €์žฅํ•ด๋‘๋ฉด ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ์„ค์ •ํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

{
  "targetUrl": "blog.saltfactory.net",
  "access_token": "access_token",
  "output": "json"
}
var params = {
  page:1,
  count:10
};

tistory.post.list(params, function(err,body){
  console.log(body);
});

tistory command

node-tistory๋ฅผ npm install -g๋กœ ์„ค์น˜๋ฅผ ํ•˜๋ฉด tistory ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๋งŒ์•ฝ $HOME/.tistory.json ํŒŒ์ผ์— ์„ค์ •์ด ์ €์žฅ๋œ ์ƒํƒœ๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ช…๋ น์–ด ์‚ฌ์šฉ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

๋ช…๋ น์–ด ์˜ต์…˜ ์„ค๋ช…
-help, --h ๋„์›€๋ง
-pretty indent ์ถ”๊ฐ€ํ•ด์„œ JSON ํ”„๋ฆฐํŠธ
ํŒŒ๋ผ๋ฏธํ„ฐ ์˜ต์…˜ ์„ค๋ช…
-ํŒŒ๋ผ๋ฏธํ„ฐ๋ช… ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ด๋ฆ„ ์•ž์— -๋ฅผ ๋ถ™์ด๊ณ  ๋’ค์— ๊ฐ’์„ ์ง€์ •

tistory.blog.info

tistory blog info -pretty

tistory.post.list

tistory post list -page 1 -count 10 -output json

tistory.post.read

tistory post read 105 --pretty

tistory.post.write

tistory post write -title ์•ˆ๋…•ํ•˜์„ธ์š” -content ํ…Œ์ŠคํŠธ์ž…๋‹ˆ๋‹ค. -tag ํƒœ๊ทธ1,ํƒœ๊ทธ2

tistory.post.modify

tistory post write -postId 105 -title ์•ˆ๋…•ํ•˜์„ธ์š” -content ํ…Œ์ŠคํŠธ์ž…๋‹ˆ๋‹ค. -tag ํƒœ๊ทธ1,ํƒœ๊ทธ2

tistory.post.attach

tistory post attach -file /Users/saltfactory/Documents/test.png

tistory.category.list

tistory category list --pretty

tistory.category.find

tistory category find Node.js --pretty

Copyright and License

The MIT License (MIT)

Copyright (c) 2014 SungKwang Song

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Tistory API client module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published