Tistory API for Client Side
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist add: with bower Sep 2, 2018
src
.gitignore initial: publish repository Sep 2, 2018
LICENSE
README.md
bower.json
index.js initial: publish repository Sep 2, 2018
package.json

README.md

tistory

Tistory API for Client Side

Installation

with Node.js

npm install --save tistory

with Bower

bower install tistory --save

Basic usage

<button id="request">Request</button>

with bower

<body>
  <script src="bower_components/tistory/dist/tistory.min.js"></script>
  <script>
    if(location.hash) {
      const 
        access_token = location.hash
          .split('#access_token=')[1]
          .split('&')[0],
        api = Tistory(access_token)
      ;

      let reqeust = document.getElementById('request');
      reqeust.addEventListener('click', () => {
        api.post.list({
          blogName: 'example',
          output: 'json'
        }, (request) => {
          /** https://www.w3schools.com/js/js_ajax_http.asp */
          console.log(request.responseText);
        });
      });
    }
  </script>
</body>

with Bundlers

const 
  tistory = require('tistory')
;
if(location.hash) {
  const 
    access_token = location.hash
      .split('#access_token=')[1]
      .split('&')[0],
    api = tistory(access_token)
  ;

  let reqeust = document.getElementById('request');
  reqeust.addEventListener('click', () => {
    api.post.list({
      blogName: 'example',
      output: 'json'
    }, (request) => {
      /** https://www.w3schools.com/js/js_ajax_http.asp */
      console.log(request.responseText);
    });
  });
}

Methods

https://www.tistory.com/guide/api/index

Parameters

  • options: object - Tistory api request parameters
  • callback: Function - the function that will be called after request

Usage

const api = tistory(access_token);

api.__CATEGORY__.__METHOD__({
  /** Reqeust Options */
}, (request, aEvt) => {
  /** XMLHttpRequest.onload */
})

Categories

Tistory.blog

Methods

  • Tistory.blog.info

Tistory.post

Methods

  • Tistory.post.list
  • Tistory.post.write
  • Tistory.post.modify
  • Tistory.post.read
  • Tistory.post.attach
  • Tistory.post.delete

Tistory.category

Methods

  • Tistory.category.list

Tistory.comment

Methods

  • Tistory.comment.list
  • Tistory.comment.newest
  • Tistory.comment.write
  • Tistory.comment.modify
  • Tistory.comment.delete

Tistory.guestbook

Methods

  • Tistory.guestbook.list
  • Tistory.guestbook.write
  • Tistory.guestbook.modify
  • Tistory.guestbook.delete

Form Request

post

<!-- File Upload -->
<form method="POST" enctype="multipart/form-data" id="upload_form">
  <input type="hidden" name="blogName" value="__BLOG_NAME__">
  <input type="file" name="uploadedfile">
  <input type="submit">
</form>
let uploadForm = document.getElementById('upload_form');
uploadForm.addEventListener('submit', (e) => {
  e.preventDefault();
  api.post.attach({
    form: uploadForm
  }, (request) => {
    console.log(request.responseText);
  });
});

get

<form method="GET" action="/" id="form_request">
  <input type="text" name="blogName" value="__BLOG_NAME__">
  <input type="hidden" name="output" value="json">
  <input type="submit">
</form>
let form = document.getElementById('form_request');
form.addEventListener('submit', (e) => {
  e.preventDefault();
  api.post.list({
    form: form
  }, (request) => {
    console.log(request.responseText);
  });
});

License

MIT

Copyright (c) Mansu Jeong. All rights reserved.