Reputation: 95
I am trying to read in all tweets based on a hashtag within the United States. Usually after paging through all of the tweets I end up with around 400 to 500 tweets, which doesn't seem like a lot to me. I'm currently using node.js/express and twitter-npm
var express = require('express');
var router = express.Router();
var Twitter = require('twitter');
var client = new Twitter({
consumer_key : "...",
consumer_secret : "...",
access_token_key : "...",
access_token_secret : "..."
});
//The ID for the United States place_type in the Twitter API
var USAID = '96683cc9126741d1';
/* GET home page. */
router.get('/', function(req, res, next) {
var moreTweets = function(id){
console.log(id);
client.get('search/tweets.json', {q : "place:" + USAID +" #haiku OR #dog", count : 100 , max_id : id}, function(error, tweets, response){
//If we get error back form twitter API we'll log it to the console
if(error){
console.log(error);
throw error;
}
//BaseCase no statuses are returned
if(tweets.statuses.length > 0){
var message = "";
for(i = 0; i < tweets.statuses.length; i++){
var currentTweet = tweets.statuses[i];
//Do work on the crrent tweet
console.log(currentTweet);
}
var lastTweet = tweets.statuses[tweets.statuses.length - 1].id_str;
moreTweets(lastTweet);
}
}
)}
moreTweets(null);
res.end();
});
Upvotes: 0
Views: 123
Reputation: 2064
Consult this page: https://dev.twitter.com/rest/reference/get/search/tweets
Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
I guess they have some limit for a search...
Upvotes: 1