Twitter API: Fetch tweets withing the last 4 hours - twitter

I have a small program that fetch tweets and displays them in google maps, it works perfect but I would like to know if there is a way to put a timeframe, for instance lets say I would like to fetch the tweets written in the last 4 hours, is it possible? Thanks for your help!
The program is written in PHP and javaScript.

It may be possible using the max_id and since_id parameters. How you would calculate finding an ID within that 4 hour window, I am unsure, but this post might provide some answers: https://stackoverflow.com/a/6416836/5884189

I just coded a solution to the same problem in a similar question. Check the answer and change the WINDOW constant to 4 to get the tweets in the last four hours. Good luck!
PS: I think the mods don't want you to repeat similar answers in 2 questions so I let you the link, but I could edit the answer later and paste the code here if I'm wrong.

Related

Trying to search reddit submissions and subreddits based on comment word search

Can you search for submissions (over all subreddits) to find those having a particular keyword use in the discussions i.e comments of that submission?
I am trying to :
Collect all the submission ids and hence the comments that have this word say "awesome".
I would also like to know if there are some subreddits that are likely to have this word used often based on the comments?
I have already looked at PRAW & PSAW documentation and even found the exact solution to this problem i.e the aggs paramter but apparently it is not working at the moment? Every query gives me a JSON that is empty(with the same code as in the documentation)?
I was wondering if there are alternatives or workarounds to this? Or something that could solve my problem.
Thanks in advance for your time.

How to get share counts from Twitter

Since 20 November, its' not possible to get Twitter share counts in this way:
http://cdn.api.twitter.com/1/urls/count.json?url=
Is there alternative to do that or it's not possible? Thanks.
Check out http://opensharecount.com, it provides a drop-in replacement for that URL. Only downside is it only can 'see' tweets from up to seven days ago, but it will include those in future counts so it is a good way to get approximate counts for your new posts.

Can I obtain the most popular sub-reddits during a specified time frame using Reddit API PRAW?

Let's say I need to obtain the text (post and all comments) from the sub-reddits that were most popular during December 2014 and January 2015. How can that be done using PRAW? I was wondering, just like Twitter doesn't let us crawl tweets which are more than a week old, is there any such time constraint in place in case of Reddit?
PRAW has a limit of 1,000 for how far back you can get threads from a subreddit based on score, newness, "hotness" (I'm not sure if that one still works) or "controversy" (I haven't tried that one in a while, as well). Unfortunately, the most popular subreddits have had too many posts to look that far back.
You can try using search() http://praw.readthedocs.org/en/latest/pages/code_overview.html#praw.init.UnauthenticatedReddit.search to get the values you want, but it requires a bit more work.

Issues getting tweets from Twitter API by date range

Good evening, StackOverflow!
I am working with twitter API to retrieve tweets from the twitter. I need to receive tweets by a time range, for example, all tweets from #someUser for the last week, or last 10 days... or from March to April.
I am looking at https://dev.twitter.com/rest/reference/get/statuses/user_timeline documentation, and it doesn't really specify how to use the date to narrow down the list of receiving tweets. I mean, I can use since_id or max_id, but it is not really what I'm looking for.
I mean, I can receive tweets by one using max_id and since_id, check the date, and see if it falls into my time frame, and continue until I get to the edge. Anyway, it is not a good practice.
So, is there a way or maybe I missed something in the documentation?
I really would appreciate any help (just a tip would work).

Unable to get more than 7 days of tweets using search.twitter.com

Is it possible to get more than 6-9 days old data(tweets) using "https://search.twitter.com/search.json?q=" I've tried multiple things mentioned at https://dev.twitter.com/docs/api/1/get/search and https://dev.twitter.com/docs/using-search but still not able to get more than 7 days old tweets.
I can see older tweets using the UI (twitter.com) but not through search.twitter.com query string which is my actual requirement.
Is it a known thing ? or am i missing something here? Please help !!
Nope, this is a limitation of the Twitter Search API. You can find it documented here:
You cannot use the Search API to find Tweets older than about a
week.
If you need Tweets older than a week Gnip offers historical Tweets all the way back to the very first Tweet from #jack.
https://gnip.com/sources/twitter/
Disclosure: I work at Gnip.

Resources