Skip to content

Commit

Permalink
0.3.0: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yu committed Jul 8, 2014
1 parent 0f41838 commit b5bcb1c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,40 @@ $ npm install duoshuo
var Duoshuo = require('duoshuo');

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

// fetch token
duoshuo.auth(code, function(err,token){
console.log(token)
// to sth with 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: {},
user: {},
}, function(err,user){
console.log(err,user)
console.log(err,user)
});

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

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

````

Expand Down
13 changes: 13 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var duoshuo = require('../index');

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

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

duoshuoClient.get('abc/def.json', {}, function(err, res, body){

});

0 comments on commit b5bcb1c

Please sign in to comment.