基本都是 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;
// 获取热门文章
hive.api.getDiscussionsByHot(query, function(err, result) {
console.log(err, result)
})
eg:
hive.api.getDiscussionsByHot({tag: 'photography', limit: 1}, function(err, result) {
console.log(err, result)
})
//获取某标签的趁势热贴(只有7天的)
hive.api.getDiscussionsByTrending({tag: 'photography', limit: 1}, function(err, result) {
console.log(err, result)
});
eg:
getTrending(){
let query = { tag: "cn", limit : 20 }
hive.api.getDiscussionsByTrending(query, function(err, data) {
//取到最后一篇文章的author和Permlink,做为下一次查询的起始点
author.value = data[data.length - 1].author
permlink.value = data[data.length - 1].permlink
})
}
//获取新帖(所有日期的)
hive.api.getDiscussionsByCreated({tag: 'photography', limit: 1}, function(err, result) {
console.log(err, result)
})
RE: Hivejs开发实战指南