tistory

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 14 Imported by: 0

README ยถ

tistory-go

Go Chromedp

๐ŸŽฏ tistory-go ๋Š” ํ‹ฐ์Šคํ† ๋ฆฌ ๋ธ”๋กœ๊ทธ(tistory blog) ์ž๋™ํ™”๋ฅผ ์œ„ํ•œ Go ์–ธ์–ด Library ์ž…๋‹ˆ๋‹ค.

โš™๏ธ Installation

As a library

go get github.com/LimJiAn/tistory-go

๐Ÿ‘€ Usage

Your Go app you can do something like

๐Ÿ“– Authorization (์ธ์ฆ ๋ฐ ๊ถŒํ•œ)
package main

import (
    "log"
    "os"

    "github.com/LimJiAn/tistory-go"
)

func main() {
    clientId := "your-client-id"
    clientSecret := "your-client-secret"
    blogURL := "your-blog-url"

    // Create Tistory
    tistory, err := tistory.NewTistory(blogURL, clientId, clientSecret)
    if err != nil {
    	log.Fatal(err)
    }

    // Get AuthorizationCode
    blogId := "your-blog-id"
    blogPassword := "your-blog-password"
    _, err = tistory.GetAuthorizationCode(blogId, blogPassword)
    if err != nil {
         log.Fatal(err)
    }

    // Get AccessToken
    _, err = tistory.GetAccessToken()
    if err != nil {
         log.Fatal(err)
    }
}
๐Ÿ“– BlogInfo (๋ธ”๋กœ๊ทธ ์ •๋ณด)
    // Blog Info
    info, err := tistory.GetBlogInfo()
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– PostList (๊ธ€ ๋ชฉ๋ก)
    // Post List
    res, err := tistory.GetPostList(1)
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– ReadPost (๊ธ€ ์ฝ๊ธฐ)
    // Read Post
    res, err := tistory.GetPost(1)
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– WritePost (๊ธ€ ์ž‘์„ฑ)
    // Write Post
    res, err := tistory.WritePost(
        map[string]interface{}{"title": "title", "content": "content", "visibility": "3"})
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– ModifyPost (๊ธ€ ์ˆ˜์ •)
    // Modify Post
    res, err := tistory.ModifyPost(
        map[string]interface{}{"postId": "1", "title": "title", "content": "content", "visibility": "3"})
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– AttchFile (ํŒŒ์ผ ์ฒจ๋ถ€)
    // Attach File (only image)
    fileName := "/UserFilepath/test.png"
    res, err := tistory.AttachPost(fileName)
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– CategoryList (์นดํ…Œ๊ณ ๋ฆฌ ๋ชฉ๋ก)
    // Category List
    res, err := tistory.CategoryList()
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– RecentComment (์ตœ๊ทผ ๋Œ“๊ธ€ ๋ชฉ๋ก)
    // Recent Comment List
    res, err := tistory.GetRecentCommentList(1, 1)
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– CommentList (๊ฒŒ์‹œ๊ธ€ ๋Œ“๊ธ€ ๋ชฉ๋ก)
    // Comment List
    res, err := tistory.GetCommentList(1)
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– WriteComment (๋Œ“๊ธ€ ์ž‘์„ฑ)
    // Write Comment
    res, err := tistory.WriteComment(
        map[string]interface{}{"postId": "1", "content": "comment"})
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– ModifyComment (๋Œ“๊ธ€ ์ˆ˜์ •)
    // Modify Comment
    info, err := tistory.ModifyComment(
        map[string]interface{}{"postId": "1", "commentId": "1", "content": "comment"})
    if err != nil {
        log.Fatal(err)
    }
๐Ÿ“– DeleteComment (๋Œ“๊ธ€ ์‚ญ์ œ)
    // Delete Comment
    info, err := tistory.DeleteComment(
        map[string]interface{}{"postId": "1", "commentId": "1"})
    if err != nil {
        log.Fatal(err)
    }

๐Ÿ“š Reference

Tistory App Register
Tistory Open API

API ์‚ฌ์šฉ ์ค‘ status 403 , error_message ์ด ๋ธ”๋กœ๊ทธ๋Š” ๋‚ด๋ถ€ ์ •์ฑ…์œผ๋กœ OPEN API ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
-> ์ŠคํŒธ์„ฑ ๊ฒŒ์‹œ๋ฌผ ์ž‘์„ฑ์ด ์ฆ๊ฐ€ํ•˜์—ฌ ์ด์šฉ์ด ์ œํ•œ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Documentation ยถ

Index ยถ

Constants ยถ

This section is empty.

Variables ยถ

This section is empty.

Functions ยถ

This section is empty.

Types ยถ

type Tistory ยถ

type Tistory struct {
	BlogURL            string
	BlogName           string
	ClientId           string
	ClientSecret       string
	AccessToken        string
	AuthenticationURL  string
	RedirectAuthURL    string
	AuthenticationCode string
}

func NewTistory ยถ

func NewTistory(blogURL, clientId, clientSecret string) (*Tistory, error)

func (*Tistory) AttachPost ยถ

func (t *Tistory) AttachPost(filePath string) (map[string]interface{}, error)

AttachPost ํŒŒ์ผ ์ฒจ๋ถ€ blogName: Blog Name uploadedfile: ์—…๋กœ๋“œํ•  ํŒŒ์ผ (multipart/form-data) https://tistory.github.io/document-tistory-apis/apis/v1/post/attach.html

func (*Tistory) CategoryList ยถ

func (t *Tistory) CategoryList() (map[string]interface{}, error)

CategoryList ์นดํ…Œ๊ณ ๋ฆฌ ๋ชฉ๋ก id: ์นดํ…Œ๊ณ ๋ฆฌ ID name: ์นดํ…Œ๊ณ ๋ฆฌ ์ด๋ฆ„ parent: ๋ถ€๋ชจ ์นดํ…Œ๊ณ ๋ฆฌ ID label: ๋ถ€๋ชจ ์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ํฌํ•จํ•œ ์ „์ฒด ์ด๋ฆ„ ('/'๋กœ ๊ตฌ๋ถ„) entries: ์นดํ…Œ๊ณ ๋ฆฌ๋‚ด ๊ธ€ ์ˆ˜

func (*Tistory) DeleteComment ยถ

func (t *Tistory) DeleteComment(option map[string]interface{}) (map[string]interface{}, error)

DeleteComment ๋Œ“๊ธ€ ์‚ญ์ œ blogName: Blog Name (ํ•„์ˆ˜) postId: ๊ธ€ ID (ํ•„์ˆ˜) commentId: ๋Œ“๊ธ€ ID (ํ•„์ˆ˜) https://tistory.github.io/document-tistory-apis/apis/v1/comment/delete.html

func (*Tistory) GetAuthorizationCode ยถ

func (t *Tistory) GetAuthorizationCode(id, password string) (string, error)

Login & Get AuthorizationCode https://tistory.github.io/document-tistory-apis/auth/authorization_code.html

func (*Tistory) GetBlogInfo ยถ

func (t *Tistory) GetBlogInfo() (map[string]interface{}, error)

GetBlogInfo ๋ธ”๋กœ๊ทธ ์ •๋ณด access_token: ๋ฐœ๊ธ‰๋ฐ›์€ access_token output: ์ถœ๋ ฅ๋ฐฉ์‹ https://tistory.github.io/document-tistory-apis/apis/v1/blog/list.html

func (*Tistory) GetCommentList ยถ

func (t *Tistory) GetCommentList(postId int) (map[string]interface{}, error)

GetCommentList ๋Œ“๊ธ€ ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ blogName: Blog Name postId: ๊ธ€ ๋ฒˆํ˜ธ (ID) https://tistory.github.io/document-tistory-apis/apis/v1/comment/list.html

func (*Tistory) GetPost ยถ

func (t *Tistory) GetPost(postId int) (map[string]interface{}, error)

GetPost ๊ธ€ ์ฝ๊ธฐ blogName: Blog Name (ํ•„์ˆ˜) postId: ๊ธ€ ๋ฒˆํ˜ธ (ํ•„์ˆ˜) https://tistory.github.io/document-tistory-apis/apis/v1/post/read.html

func (*Tistory) GetPostList ยถ

func (t *Tistory) GetPostList(pageNumber int) (map[string]interface{}, error)

GetPostList ๊ธ€ ๋ชฉ๋ก blogName: Blog Name (ํ•„์ˆ˜) page: ๋ถˆ๋Ÿฌ์˜ฌ ํŽ˜์ด์ง€ ๋ฒˆํ˜ธ https://tistory.github.io/document-tistory-apis/apis/v1/post/list.html

func (*Tistory) GetRecentCommentList ยถ

func (t *Tistory) GetRecentCommentList(page, count int) (map[string]interface{}, error)

GetComment ์ตœ์‹  ๋Œ“๊ธ€ ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ blogName: Blog Name page: ๊ฐ€์ ธ์˜ฌ ํŽ˜์ด์ง€ (๊ธฐ๋ณธ๊ฐ’: 1) count: ํŽ˜์ด์ง€๋‹น ๋Œ“๊ธ€ ์ˆ˜ (๊ธฐ๋ณธ๊ฐ’: 10, ์ตœ๋Œ€๊ฐ’: 10) https://tistory.github.io/document-tistory-apis/apis/v1/comment/recent.html

func (*Tistory) ModifyComment ยถ

func (t *Tistory) ModifyComment(option map[string]interface{}) (map[string]interface{}, error)

ModifyComment ๋Œ“๊ธ€ ์ˆ˜์ • blogName: Blog Name (ํ•„์ˆ˜) postId: ๊ธ€ ID (ํ•„์ˆ˜) commentId: ๋Œ“๊ธ€ ID (ํ•„์ˆ˜) parentId: ๋ถ€๋ชจ ๋Œ“๊ธ€ ID (๋Œ€๋Œ“๊ธ€์ธ ๊ฒฝ์šฐ ์‚ฌ์šฉ) content: ๋Œ“๊ธ€ ๋‚ด์šฉ secret: ๋น„๋ฐ€ ๋Œ“๊ธ€ ์—ฌ๋ถ€ (1: ๋น„๋ฐ€๋Œ“๊ธ€, 0: ๊ณต๊ฐœ๋Œ“๊ธ€ - ๊ธฐ๋ณธ ๊ฐ’) https://tistory.github.io/document-tistory-apis/apis/v1/comment/modify.html

func (*Tistory) ModifyPost ยถ

func (t *Tistory) ModifyPost(option map[string]interface{}) (map[string]interface{}, error)

ModifyPost ๊ธ€ ์ˆ˜์ • blogName: Blog Name (ํ•„์ˆ˜) postId: ๊ธ€ ๋ฒˆํ˜ธ (ํ•„์ˆ˜) title: ๊ธ€ ์ œ๋ชฉ (ํ•„์ˆ˜) content: ๊ธ€ ๋‚ด์šฉ visibility: ๋ฐœํ–‰์ƒํƒœ (0: ๋น„๊ณต๊ฐœ - ๊ธฐ๋ณธ๊ฐ’, 1: ๋ณดํ˜ธ, 3: ๋ฐœํ–‰) category: ์นดํ…Œ๊ณ ๋ฆฌ ์•„์ด๋”” (๊ธฐ๋ณธ๊ฐ’: 0) published: ๋ฐœํ–‰์‹œ๊ฐ„ (TIMESTAMP ์ด๋ฉฐ ๋ฏธ๋ž˜์˜ ์‹œ๊ฐ„์„ ๋„ฃ์„ ๊ฒฝ์šฐ ์˜ˆ์•ฝ. ๊ธฐ๋ณธ๊ฐ’: ํ˜„์žฌ์‹œ๊ฐ„) slogan: ๋ฌธ์ž ์ฃผ์†Œ tag: ํƒœ๊ทธ (',' ๋กœ ๊ตฌ๋ถ„) acceptComment: ๋Œ“๊ธ€ ํ—ˆ์šฉ (0, 1 - ๊ธฐ๋ณธ๊ฐ’) password: ๋ณดํ˜ธ๊ธ€ ๋น„๋ฐ€๋ฒˆํ˜ธ https://tistory.github.io/document-tistory-apis/apis/v1/post/modify.html

func (*Tistory) WriteComment ยถ

func (t *Tistory) WriteComment(option map[string]interface{}) (map[string]interface{}, error)

WriteComment ๋Œ“๊ธ€ ์ž‘์„ฑ blogName: Blog Name (ํ•„์ˆ˜) postId: ๊ธ€ ID (ํ•„์ˆ˜) parentId: ๋ถ€๋ชจ ๋Œ“๊ธ€ ID (๋Œ€๋Œ“๊ธ€์ธ ๊ฒฝ์šฐ ์‚ฌ์šฉ) content: ๋Œ“๊ธ€ ๋‚ด์šฉ secret: ๋น„๋ฐ€ ๋Œ“๊ธ€ ์—ฌ๋ถ€ (1: ๋น„๋ฐ€๋Œ“๊ธ€, 0: ๊ณต๊ฐœ๋Œ“๊ธ€ - ๊ธฐ๋ณธ ๊ฐ’) https://tistory.github.io/document-tistory-apis/apis/v1/comment/write.html

func (*Tistory) WritePost ยถ

func (t *Tistory) WritePost(option map[string]interface{}) (map[string]interface{}, error)

WritePost ๊ธ€ ์ž‘์„ฑ blogName: Blog Name (ํ•„์ˆ˜) title: ๊ธ€ ์ œ๋ชฉ (ํ•„์ˆ˜) content: ๊ธ€ ๋‚ด์šฉ visibility: ๋ฐœํ–‰์ƒํƒœ (0: ๋น„๊ณต๊ฐœ - ๊ธฐ๋ณธ๊ฐ’, 1: ๋ณดํ˜ธ, 3: ๋ฐœํ–‰) category: ์นดํ…Œ๊ณ ๋ฆฌ ์•„์ด๋”” (๊ธฐ๋ณธ๊ฐ’: 0) published: ๋ฐœํ–‰์‹œ๊ฐ„ (TIMESTAMP ์ด๋ฉฐ ๋ฏธ๋ž˜์˜ ์‹œ๊ฐ„์„ ๋„ฃ์„ ๊ฒฝ์šฐ ์˜ˆ์•ฝ. ๊ธฐ๋ณธ๊ฐ’: ํ˜„์žฌ์‹œ๊ฐ„) slogan: ๋ฌธ์ž ์ฃผ์†Œ tag: ํƒœ๊ทธ (',' ๋กœ ๊ตฌ๋ถ„) acceptComment: ๋Œ“๊ธ€ ํ—ˆ์šฉ (0, 1 - ๊ธฐ๋ณธ๊ฐ’) password: ๋ณดํ˜ธ๊ธ€ ๋น„๋ฐ€๋ฒˆํ˜ธ https://tistory.github.io/document-tistory-apis/apis/v1/post/write.html

Directories ยถ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL