var options = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json?',
qs: { "screen_name": "Screen_name"} ,
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};
request(options, function(error, response, body){
console.log("length",body.length)
});
我正在尝试获取所有tweets,但出于某种原因,我只获得20条,如果API调用最多可以获取3200条tweets。
所以我想知道我怎样才能得到这个帐户的所有tweets(目前为700多条)
我看到一个计数被列出,但出于某种原因,我找不到开始一段的方法。
希望有人能帮助我。
编辑:
在pii eu-kee回复后,我得出结论,这是获得所有tweet需要做的:
var firstOptions = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json',
qs: {"screen_name": "Company", "count": 200},
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};
var array = [];
var go = true;
async.whilst(function () {
return go;
},function(next){
request(firstOptions, function (error, response, body) {
firstOptions.qs.max_id = body[body.length - 1].id;
array = array.concat(body);
if(body.length !== 200) {
go = false;
}
next();
});
});