Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Latest commit

Β 

History

History
167 lines (130 loc) Β· 4.84 KB

post.rst

File metadata and controls

167 lines (130 loc) Β· 4.84 KB

Post API

κ²Œμ‹œκΈ€ λͺ©λ‘ 쑰회

졜근 κ²Œμ‹œλ¬Ό λͺ©λ‘μ„ κ°€μ Έμ˜¬ 수 μžˆλŠ” APIμž…λ‹ˆλ‹€. ν•΄λ‹Ή API에 κ΄€ν•œ μ •λ³΄λŠ” κ²Œμ‹œλ¬Ό λͺ©λ‘ API λ₯Ό 톡해 μ‚΄νŽ΄λ³΄μ‹€ 수 μžˆμŠ΅λ‹ˆλ‹€.

from pytistory import PyTistory

pytistory = PyTistory()
pytistory.configure()

response = pytistory.post.list(blog_name='oauth')

결과값은 μ•„λž˜μ²˜λŸΌ 받을 수 μžˆμŠ΅λ‹ˆλ‹€.

{
  "status": "200",
  "item": {
    "url": "http://oauth.tistory.com",
    "secondaryUrl": "",
    "page": "1",
    "count": "10",
    "totalCount": "4",
    "posts": {
      "post": [
        {
          "id": "4",
          "title": "ν‹°μŠ€ν† λ¦¬ OAuth Open API 일단 μ¨λ³΄μ„Έμš”!",
          "postUrl": "http://oauth.tistory.com /4",
          "visibility": "0",
          "categoryId": "0",
          "comments": "6",
          "trackbacks": "0",
          "date": "1303796661"
        },
        {
          "id": "3",
          "title": "View에 λ³΄λƒ…λ‹ˆλ‹€~",
          "postUrl": "http://oauth.tistory.com /3",
          "visibility": "3",
          "categoryId": "0",
          "comments": "0",
          "trackbacks": "0",
          "date": "1303372106"
        },
        {
          "id": "2",
          "title": "View에 λ³΄λ‚΄λ΄…λ‹ˆλ‹€.",
          "postUrl": "http://oauth.tistory.com /2",
          "visibility": "3",
          "categoryId": "0",
          "comments": "0",
          "trackbacks": "0",
          "date": "1303372007"
        },
        {
          "id": "1",
          "title": "ν‹°μŠ€ν† λ¦¬ OAuth2.0 API μ˜€ν”ˆ!",
          "postUrl": "http://oauth.tistory.com /1",
          "visibility": "0",
          "categoryId": "0",
          "comments": "0",
          "trackbacks": "0",
          "date": "1303352668"
        }
      ]
    }
  }
}

κ²Œμ‹œκΈ€ μž‘μ„±

κ²Œμ‹œκΈ€μ„ μž‘μ„±ν•  수 μžˆλŠ” APIμž…λ‹ˆλ‹€. ν•΄λ‹Ή API에 κ΄€ν•œ μ •λ³΄λŠ” κ²Œμ‹œκΈ€ μž‘μ„± API λ₯Ό 톡해 μ‚΄νŽ΄λ³΄μ‹€ 수 μžˆμŠ΅λ‹ˆλ‹€.

from pytistory import PyTistory

pytistory = PyTistory()
pytistory.configure()

response = pytistory.post.write("Post Title",
                                blog_name='sampleUrl',
                                visibility=1,
                                category=12,
                                content="Post Content",
                                tag=["Tag1", "Tag2"])

μΈμžλŠ” λ‹€μŒμ²˜λŸΌ λ°›μŠ΅λ‹ˆλ‹€.

title

포슀트 제λͺ©μž…λ‹ˆλ‹€. strνƒ€μž…μž…λ‹ˆλ‹€.

blog_name

λΈ”λ‘œκ·Έ λͺ…μž…λ‹ˆλ‹€. 기본값은 None. strνƒ€μž…μž…λ‹ˆλ‹€.

target_url

λΈ”λ‘œκ·Έμ˜ urlμž…λ‹ˆλ‹€. deprecated된 μ˜΅μ…˜μž…λ‹ˆλ‹€. 기본값은 None. strνƒ€μž…μž…λ‹ˆλ‹€.

visibility
  • 0: λΉ„κ³΅κ°œ
  • 1: 보호
  • 2: 곡개
  • 3: λ°œν–‰

기본값은 0μž…λ‹ˆλ‹€.

published

λ°œν–‰ μ‹œκ°„. λ§Œμ•½ μ„€μ •μ‹œ μ˜ˆμ•½ λ°œν–‰μ΄ 됨., None. νƒ€μž…μ€ datetime.datetimeνƒ€μž…μž…λ‹ˆλ‹€.

category

μΉ΄ν…Œκ³ λ¦¬λ₯Ό λœ»ν•˜κ³ , 0은 λΆ„λ₯˜μ—†μŒμž…λ‹ˆλ‹€. κ°’ μ„€μ •μ‹œ μΉ΄ν…Œκ³ λ¦¬κ°€ μ„€μ •λ©λ‹ˆλ‹€. 기본값은 0μž…λ‹ˆλ‹€.

content

κΈ€ λ‚΄μš©, 기본값은 None이고 strνƒ€μž…μž…λ‹ˆλ‹€.

slogan

문자 μ£Όμ†Œ. μ΄λŠ” μ•„λ§ˆ λΈ”λ‘œκ·Έ μ£Όμ†Œ ν˜•μ‹μ„ 문자둜 μ„€μ •ν–ˆμ„ λ•Œμ˜ 값인 λ“― ν•©λ‹ˆλ‹€. 기본값은 None.

tag

κ²Œμ‹œκΈ€μ— νƒœκ·Έλ₯Ό μ„€μ •ν•©λ‹ˆλ‹€, 기본값은 None. κ°’ μ„€μ •ν•  λ•Œ νƒ€μž…μ€ listμž…λ‹ˆλ‹€.

결과값은 μ•„λž˜μ²˜λŸΌ 받을 수 μžˆμŠ΅λ‹ˆλ‹€.

{
  "status": "200",
  "postId": "74",
  "url": "http://sampleUrl.tistory.com/74"
}

κ²Œμ‹œκΈ€ μˆ˜μ •

μž‘μ„±λœ κ²Œμ‹œκΈ€μ„ μˆ˜μ •ν•  수 μžˆλŠ” APIμž…λ‹ˆλ‹€. ν•΄λ‹Ή API에 κ΄€ν•œ μ •λ³΄λŠ” κ²Œμ‹œκΈ€ μˆ˜μ • API λ₯Ό 톡해 μ‚΄νŽ΄λ³΄μ‹€ 수 μžˆμŠ΅λ‹ˆλ‹€.

from pytistory import PyTistory

pytistory = PyTistory()
pytistory.configure()

response = pytistory.post.modify("Post Title",
                                1,
                                blog_name='sampleUrl',
                                visibility=1,
                                category=12,
                                content="Post Content",
                                tag=["Tag1", "Tag2"])

μΈμžκ°’μ€ μœ„μ˜ κ²Œμ‹œκΈ€ μž‘μ„± APIμ—μ„œ, 두가지 λ³€κ²½μ‚¬ν•­λ§Œ μžˆμŠ΅λ‹ˆλ‹€.

published값을 μ„€μ •ν•  수 μ—†κ³ , intνƒ€μž…μ˜ post_idλ₯Ό μΆ”κ°€μ μœΌλ‘œ 전달해주어야 ν•©λ‹ˆλ‹€.

결과값은 μ•„λž˜μ²˜λŸΌ 받을 수 μžˆμŠ΅λ‹ˆλ‹€.

{
  "status": "200",
  "postId": "74",
  "url": "http://sampleUrl.tistory.com/74"
}