getDiscussionsByXXX
//query的参数结构
string tag;
uint32_t limit = 0;
set<string> filter_tags;
set<string> select_authors;
set<string> select_tags;
uint32_t truncate_body = 0;
optional<string> start_author;
optional<string> start_permlink;
optional<string> parent_author;
optional<string> parent_permlink;
//Get Discussions By Hot 获取热门文章
steem.api.getDiscussionsByHot(query, function(err, result) {
console.log(err, result)
})
eg:
steem.api.getDiscussionsByHot({tag: 'photography', limit: 1}, function(err, result) {
console.log(err, result)
})
//获取某标签的趁势热贴(只有7天的)
steem.api.getDiscussionsByTrending({tag: 'photography', limit: 1}, function(err, result) {
console.log(err, result)
});
eg:
getTrending(){
let that = this
let query = { tag: "cn", limit : 20 }
this.steem.api.getDiscussionsByTrending(query, function(err, data) {
that.posts = data
//取到最后一篇文章的author和Permlink,做为下一次查询的起始点
that.author = data[data.length - 1].author
that.permlink = data[data.length - 1].permlink
})
},
getNext(){
let that = this
let query = {tag: "cn", limit: 20, start_author: this.author, start_permlink: this.permlink}
this.steem.api.getDiscussionsByTrending(query, function(err, data) {
data.forEach(post => {
if (post.permlink != that.permlink) {
that.posts.push(post)
}
})
//取到最后一篇文章的author和Permlink,做为下一次查询的起始点
that.author = data[data.length - 1].author
that.permlink = data[data.length - 1].permlink
if(data.length == 1){
alert('没有更多了!')
}
})
}
//获取新帖(所有日期的)
steem.api.getDiscussionsByCreated({tag: 'photography', limit: 1}, function(err, result) {
console.log(err, result)
})
RE: SteemJS中文手册