我怎样才能获得超过最近 15 条推文的信息?
How can I get more than the last 15 Tweets?
我正在为节点使用 Twitter npm 包,当我查询时,我最多只能获得 15 条推文。我怎样才能获得更多结果?这是我的代码:
app.get('/', function (req, res) {
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
client.get('search/tweets', {q: hashTags}, function(error, tweets, response) {
if (!error) {
var size = Object.keys(tweets.statuses).length;
//var size = tweets.search_metadata.count;
console.log(tweets.search_metadata.count);
for(var i = 0; i<size; i++){
res.write(
"<div style='font-family: Arial; border: dashed 1px #ebd2ee; padding: 12px; margin:4px;'>" +
"<p style='font-size:20px; text-transform: UPPERCASE;'>" + tweets.statuses[i].user.name + "</p>" +
"<p style='font-size:14px;'>" + tweets.statuses[i].text + "</p>" +
"<br /><span style='font-size:14px; color:#A9A9A9;'>" + tweets.statuses[i].created_at + "</span></div>");
}
}
});
});
您只需添加计数参数即可。来自 documentation:
count (optional)
The number of tweets to return per page, up to a maximum of 100. Defaults to 15. This was formerly the “rpp” parameter in the old Search API.
我正在为节点使用 Twitter npm 包,当我查询时,我最多只能获得 15 条推文。我怎样才能获得更多结果?这是我的代码:
app.get('/', function (req, res) {
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
client.get('search/tweets', {q: hashTags}, function(error, tweets, response) {
if (!error) {
var size = Object.keys(tweets.statuses).length;
//var size = tweets.search_metadata.count;
console.log(tweets.search_metadata.count);
for(var i = 0; i<size; i++){
res.write(
"<div style='font-family: Arial; border: dashed 1px #ebd2ee; padding: 12px; margin:4px;'>" +
"<p style='font-size:20px; text-transform: UPPERCASE;'>" + tweets.statuses[i].user.name + "</p>" +
"<p style='font-size:14px;'>" + tweets.statuses[i].text + "</p>" +
"<br /><span style='font-size:14px; color:#A9A9A9;'>" + tweets.statuses[i].created_at + "</span></div>");
}
}
});
});
您只需添加计数参数即可。来自 documentation:
count (optional)
The number of tweets to return per page, up to a maximum of 100. Defaults to 15. This was formerly the “rpp” parameter in the old Search API.