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

Latest commit

Β 

History

History
270 lines (201 loc) Β· 7.46 KB

post.rst

File metadata and controls

270 lines (201 loc) Β· 7.46 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"
}

κΈ€ 읽기

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

from pytistory import PyTistory

pytistory = PyTistory()
pytistory.configure()

response = pytistory.post.read(1, blog_name='sampleUrl')

μΈμžκ°’μ€ blog_nameκ³Ό post_idλ§Œμ„ λ°›μŠ΅λ‹ˆλ‹€.

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

{
  "status": "200",
  "item": {
    "url": "http://oauth.tistory.com",
    "secondaryUrl": "",
    "id": "1",
    "title": "ν‹°μŠ€ν† λ¦¬ OAuth2.0 API μ˜€ν”ˆ!",
    "content":
      "μ•ˆλ…•ν•˜μ„Έμš” Tistory API μž…λ‹ˆλ‹€.<br><br>μ΄λ²ˆμ— Third-party Developer 용 <b>Tistory OAuth 2.0 API</b> κ°€ μ˜€ν”ˆλ©λ‹ˆλ‹€.",
    "categoryId": "0",
    "postUrl": "http://oauth.tistory.com/1",
    "visibility": "0",
    "acceptComment": "1",
    "acceptTrackback": "1",
    "tags": {
      "tag": ["open", "api"]
    },
    "comments": "0",
    "trackbacks": "0",
    "date": "1303352668"
  }
}

파일 첨뢀

νŒŒμΌμ„ 첨뢀 ν•  수 μžˆλŠ” APIμž…λ‹ˆλ‹€. ν•΄λ‹Ή API에 κ΄€ν•œ μ •λ³΄λŠ” 파일 첨뢀 API λ₯Ό 톡해 μ‚΄νŽ΄λ³΄μ‹€ 수 μžˆμŠ΅λ‹ˆλ‹€.

from pytistory import PyTistory

pytistory = PyTistory()
pytistory.configure()

response = pytistory.post.attach('./path/to/uploading/file', blog_name='sampleUrl')

μΈμžκ°’μ€ 파일의 κ²½λ‘œμ™€ λΈ”λ‘œκ·Έμ˜ 이름을 λ°›μŠ΅λ‹ˆλ‹€. μŠ€νŠΈλ¦Όμ„ ν†΅ν•œ μ—…λ‘œλ“œλŠ” μΆ”ν›„ κ΅¬ν˜„μ˜ˆμ •μž…λ‹ˆλ‹€.

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

{
  "status": "200",
  "url": "http://cfile6.uf.tistory.com/image/1328CE504DB79F5932B13F",
  "replacer":
    "%5b%23%23_1N%7ccfile6.uf%401328CE504DB79F5932B13F%7cwidth%3d\"500\"+height%3d\"300\"%7c_%23%23%5d"
}

κΈ€ μ‚­μ œ

이 APIλ₯Ό μ‚¬μš©ν•˜κΈ° μœ„ν•΄μ„œλŠ” 사전 ν˜‘μ˜κ°€ ν•„μš”ν•˜λ‹€κ³  ν•©λ‹ˆλ‹€.

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

from pytistory import PyTistory

pytistory = PyTistory()
pytistory.configure()

response = pytistory.post.delete(1, blog_name='sampleUrl')

μΈμžκ°’μ€ κΈ€μ˜ λ²ˆν˜Έμ™€ λΈ”λ‘œκ·Έμ˜ 이름을 λ°›μŠ΅λ‹ˆλ‹€.

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

{
  "status": "200"
}