twitter api getting tweets(posts) - twitter

is there a way to get tweets from some specific user and since some time of period?
I see that statuses/user_timeline has the screen_name param which I can search for specific user's tweets but can't filter these tweets by date created.
so if I want to get this user's past 1 week tweets what are some ways to do it?

Your only option is to use GET statues/user_timeline and page backwards in time until you either run out of results or get back statuses that are older then the time range of interest.

Related

Twitter API get tweets in particular time range

I'm trying to get the number of tweets in a particular time range for a user, from what I can ascertain you cant do this directly with the REST API.
My boss suggested something about people following our app to be able to get the tweets, is any of this possible? I cant seem to find the answer or will I need to get all the tweets and sort through the JSON according to when the tweet was created?
Bear in mind I'm working in Erlang.

Can I use twitter api to search tweets one week before?

I am trying to search keywords in twitter through tweepy.
However, I found it seems like that I can not search the tweets one week before, the code below is the main search code.
for searched_tweets in tweepy.Cursor( API.search,
q = "python",
since = 2014-02-03,
until = 2014-02-04,
lang='en' ).items()
I am not sure whether there is any limited or any better way to search by time, thanks for your help!!
:)
Unfortunately, you can't get tweets older than a week with the twitter search API.
Also note that the search results at twitter.com may return historical results while the Search API usually only serves tweets from the past week. - Twitter documentation.
You can get specific tweets older than a week by looking at individual users or using specific post ids (if you have them) but it's not reasonable to index every single tweet ever to be searchable using the API.
If you need a large time range, you can collect them yourself using the streaming API or check out a service that does (see this dev twitter thread for examples).

Twitter4j - Getting tweets of a particular user in a time interval

I want to get the tweets of an user in a time interval, for example a user's tweets between a 6 months period. I can get all the tweets of a user with getUserTimeline functionality but it seems like it doesn't give me any option about any date interval.
I need something like since and until parameters which is provided by Query class of Twitter4j. I would use that class but it only support searching for keywords. Is there a way to accomplish this?
Thanks in advance.
I don't believe twitter itself provides any date/time related options for getting tweets (aka user timeline statuses).
If you can extract the tweet ID for the last tweet in that 6 month window, you can set that as max_id and then iterate backwards by setting the lowest tweet ID as max_id till you hit the start of the 6 month window.
The current version does not have any provision to get the tweets between a specific time interval using date and time with getUserTimeline functionality.
It can be done using since_id and max_id only AFAIK.
User TimeLine
Search tweets

What is the best approach to working out if I have retweeted a tweet from another user, via the Twitter API?

So, I am currently working on an application that allows me to search journalists and view their contact details including, among other things, their latest tweets.
Calling the Twitter API is no problem at all, and I have a list of tweets for the current journo showing up fine. However, I am trying to decide the best approach to seeing if I (the user logged into our application) have retweeted any of the journo's tweets, so that I can display the tweet as having been retweeted.
Looking at the API documentation, I am looking into the following options:
1 - Use /statuses/retweeted_by_me to get the list of tweets that I
have retweeted, specifying max_id to be the highest id from the
list of tweets for the journo I am looking at. What I am not sure of
here is if the max_id is going to limit by the max id of my tweets or
the max id of the retweeted tweets.
2 - Use /statuses/:id/retweeted_by for each of the journo's tweets to
get a list of all the users who have retweeted that tweet and to check to
see if my user is in the returned list of users. Downfalls of this is that there
could be thousands of retweeters and I can only return a maximum of
100 at a time. That could mean a lot of requests just to find if I
retweeted one tweet. This also means that I need to do this for each
of the journo's tweets as opposed to getting the list of all my
rewteets above.
3 - Use /statuses/retweets/:id to get a list of the retweets for
each of the journo's tweets. This option has the same limitations as
#2.
I'm currently leaning towards #1, however, I'm not sure as yet if this will work. I need to do some more investigation. In the mean time, my question to you is:
What is the best approach to working out if I have retweeted a tweet from another user?
Ok, so I must have been having a brain fart moment when looking into this yesterday. It occurred to me this morning that you can simply make an authenticated call to /statuses/user_timeline which will set the retweeted property to true if you have retweeted that tweet.
Simples.

Get first tweet of a given day

Hi all
I am new to twitter API.. So my question may be a trivial one..
I am developing a new twitter widget, in which I want to get the first tweet for a given hashtag on a particular date.
say first tweet for #xyz hashtag tweeted on 12-08-10.
so far through googling and api doc I found rpp * page max = 1500.. if totaltweet for a given day is 2000 how can I retrieve last 500 tweets..
I have a few questions?
1. Is this for any hashtag that a user might request on the fly, or a set of hashtags that generally remain the same?
If it is a set of tags that stays the same for a while, roughly how many tags are there?
When you say a particular date, how far back in time are you going?
There are two standard ways to get tweets for a hashtag. You can use search, which goes back around 7 days or 1,500 tweets. For an active tag, that may only be a day or two. You can use the streaming API, but that doesn't go back, it just starts tracking from the moment you start making the request. The streaming API can track up to 400 hashtags without getting approval for a higher rate. The search API is limited to 10 to 20 hashtags per query.
If you answer questions 1-3, I can suggest a path to getting what you want.

Resources