【问题标题】:How can I get more than the last 15 Tweets?我怎样才能获得超过最后 15 条推文?
【发布时间】:2018-03-21 13:31:03
【问题描述】:

我正在为节点使用 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>");
          }
        }
      });
    });

【问题讨论】:

标签: node.js npm tweets


【解决方案1】:

您只需要添加计数参数。来自documentation

计数(可选)

每页返回的推文数量,最多 100 条。默认为 15。这以前是旧搜索 API 中的“rpp”参数。

【讨论】:

    猜你喜欢
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    • 2014-08-04
    • 1970-01-01
    • 2011-06-04
    • 1970-01-01
    • 1970-01-01
    • 2021-07-19
    相关资源
    最近更新 更多