Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
duoshuo SDK based on Node.js
JavaScript
branch: master
Failed to load latest commit information.
examples 0.3.0: update example
libs 0.3.0: 升级sdk依赖,支持直接调用底层api
test 0.2.1: 根据 sdk 0.1.1 重构,并保持 api 一致
.gitignore 0.1.1: format codes
.npmignore 0.1.1: format codes
README.md
index.js 0.2.1: format codes, split apis
package.json 0.3.0: format codes, upgrade sdk version

README.md

duoshuo duoshuo.com apis npm

duoshuo.com apis for node.js

How to install

$ npm install duoshuo

Sample code

var Duoshuo = require('duoshuo');

var duoshuo = new Duoshuo({
  short_name: 'abc', // 站点申请的多说二级域名。
  secret: 'xxx' // 站点密钥
});

// fetch token
duoshuo.auth(code, function(err,token){
  console.log(token)
  // to sth with token    
});

var access_token = 'xxxxxxxxxxxxxxxxxx';    // 通过duoshuo.auth获得的access_token
var duoshuoClient = duoshuo.getClient(access_token);

// join local user to duoshuo.com
duoshuoClient.join({
  user: {},
}, function(err,user){
  console.log(err,user)
});

// fetch top articles
duoshuoClient.tops({
  range: 'daily' // 获取本日,详见:http://dev.duoshuo.com/docs/50398b4b8551ece011000023
  num_items: 10 // 获取10篇
}, function(err, threads){
  console.log(threads)
});

// push comments to duoshuo.com
duoshuoClient.comment({
  message: '我的一条新匿名评论'   
}, function(err,comment){
  console.log(comment)
});

Run Unit-test (Mocha)

$ git clone https://github.com/turingou/duoshuo.git
$ cd duoshuo
$ npm install
$ npm test
Something went wrong with that request. Please try again.