Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter API search user's tweets between dates

Is there a way to get tweets for a certain user between dates? I tried using Search API, but no success. The user's timeline api does not have date parameters.

The only way that I found is get the 200 most recent tweets of the user and check by parsing date.

$.getJSON(
                'http://twitter.com/status/user_timeline/' + account_name + '.json?callback=?',
                function(data){
                    if (!data || data.length === 0)
                        return false;

                    var date = new Date(data[0].created_at);
                    //[Date comparison goes here]

                }
            );

I think there is a better way to to this, but searching not helped at all.

like image 399
Julio Vedovatto Avatar asked Jun 21 '11 14:06

Julio Vedovatto


People also ask

Can I search someone's tweets by date?

First, you need to know the username of the account you're searching. Then add a date range/timeframe you want to search within. So if we wanted to find a tweet from TeachThought on Jan 10, 2019, we'd simply enter this into the search box and hit the little 'hourglass' icon.

Can you get old tweets from Twitter API?

Twitter Official API has the bother limitation of time constraints, you can't get older tweets than a week.

How do I find tweets from a specific user?

First, go to your search bar and type in the phrase, "from:," followed by the account name. Click "Search," and then you will have all mentions, tweets, and media from the account you searched.


1 Answers

The search API supports this, but you have to assemble your query like so:

http://search.twitter.com/search.json?q=+from%3Atwitterapi+since%3A2011-06-20+until%3A2011-06-20

The query string above is the urlencoded form of:

q= from:twitterapi since:2011-06-20 until:2011-06-20

The list of search operators can be found here.

like image 165
arcain Avatar answered Oct 17 '22 04:10

arcain