Twitter API: Get latest nearby tweets - geolocation

I see the request API docs here: https://dev.twitter.com/docs/api/1.1/get/search/tweets
I understand that there's a geocode field. The problem is that the query field is required meaning I have to search something that's related in that area. Is it possible to just get ALL the latest tweets around that area without specifying a query?

No, this is deliberate to prevent huge demand on the servers, you need to specify something else. My tip - use the date/time related query fields. This is acceptable, and if you really need "forever", you can make more requests.

Related

Twitter api (Twitter4j). How to get US tweets?

I'm trying to get random stream US tweets by using twitter4j, but it seems there is no way I can do that.
I decided to use streaming api, because it looks like it suits for my purposes, but the thing is. I can get random tweets, using method sample(). But it returns random tweets without any ability to filter US tweets.
So I used filter method without any success, because I have to set track words and it's not actually what I need.
I tried to use not stream api and it seems that it's possible to reach my purpose, but it's bloody hell.
Does anyone know how to subscribe for US tweets in English by using stream twitter api?
Why don't you use filter mechanism in the streamin api? There is an optional parameter that you can specifically set the coordinated wherever you want, then you will be getting only the tweets determined by these coordinates.
You can have a look at following links for further info:
https://dev.twitter.com/docs/api/1.1/post/statuses/filter
https://dev.twitter.com/docs/streaming-apis/parameters#locations
However, there is no way to filter tweets in terms of language yet in Streaming API, but search API has that functionality.
With Search API, if you can live with omitting Alaska/Hawaii and including Toronto you could go with something like (geocode:"41.2,-113.6,1000km" OR geocode:"38.1,-88.3,1600km"). That gives this sort of coverage:
Or just create longer boolean that does what you want..

Tweets, Location, Keywords and Data

I'm trying do some analysis on locations where people are going during winters. The approach I'm following is get tweets from a specific city (say, New York) and with the keyword Foursquare. Then use foursquare data for that user to see his/her checkins and try to trace a pattern.
So, I'm stuck in the first phase. How do I get those tweets from ONE city and with the keyword FOURSQUARE. I'm not sure if I understood how to use streaming API correctly and the ReST API isn't working (shows NOT AUTHORISED)
Could you tell me a detailed procedure for a rookie to understand the process of doing the above mentioned process. Also, let me know if you have a better approach for analysing trends in check ins.
Thanks
You want to read these:
https://dev.twitter.com/docs/api/1/get/search
https://dev.twitter.com/docs/platform-objects/places
You can give Twitter a latitude/longitude coordinate and a radius, or you can use the "place" field as a filter. Either way, expect to fine-tune this a bit to fit your needs. You also need to take into account that a lot of people might tweet without location services enabled.
If you want to use the REST API, you need to get an API key from twitter.

How to get a list of all retweeters in Twitter?

I have seen numerous companies doing like Twitter lotteries where users got to retweet their tweet and then one of retweeters will get the prize or whatever.
I was wondering now how do they get the list of all retweeters or pick the winner?
I checked Twitter API and found only this thing: GET statuses/retweets/:id but it returns maximum of 100 retweeters. Is that the only way?
It looks likes there's a couple services out there doing almost exactly this. A quick google pulls up http://onekontest.com/ and there's a few other Twitter contest services, but they all seem to be different levels of broken since they haven't kept up with changes to the API.
As far as the Twitter API itself is concerned, if you were expecting more than 100 responses, I think using GET statuses/mentions makes the most sense. That API call returns any mentions of a user, and you can pass the flag include_rts to include any retweets of your tweets. Then, if you wanted to list RTs of a specific tweet, you could check the in_reply_to_status_id field in the returned data to see if it matches the original tweet ID. This API call only returns the last 800 status, 200 at a time, so if you expect a bunch of data, you would need to poll the API repeatedly over time to get all the tweets. I imagine services like favstar are doing exactly this, just on a larger scale.
If you're actually looking for code to do something like this, I wrote a sinatra app called twitter-rss-digest which handles querying Twitter over time to track different sorts of queries. It's pretty rough, and doesn't quite handle this specifically, but it might point you in the right direction if you want to code something.
The Twitter API has an endpoint that returns up to 100 retweeter IDs for a given tweet.
Note that for historical reasons, that endpoint only returns up to 100 results and the documentation about the cursor is useless. Twitter refused to fix the situation.
2013 note
That said, the first thread on the Developers site that surfaced in a quick google has #episod, a Twitter employee saying:
You can't likely get to all of them. The data is spread out. Your best bet is to use the REST API to determine many of the users who performed the retweet, but the data will still be constrained.
It's easiest to track retweets as they happen rather than try to find them from the past. Use the Streaming API for that.
I like muffinista's method, but I think if you want a 100% complete list of retweets, simply enable the retweet email notifications and write a script that polls the email box for those matching the subject "retweeted one of your Tweets!" and put the data into a table. Do this right from the start.
The site https://twren.ch/ enlists all the retweeters for a given tweet (note that it only enlists retweeters who are direct followers of the source tweeter.) Nevertheless its probably the only public source available.

Get follower count on Twitter API search results

What I'm trying to do is pull some search results, and sort them by users.
Right now I'm using
$to->OAuthRequest('http://search.twitter.com/search.json', array('q' => 'search-term'), 'GET');
to get the results, but I can't actually get information about the user like follower_count, etc. so I though I'd take each result's user_id, and run it through http://twitter.com/users/show.xml to get the rest of the information.
The problem is, if I get 50 results that way, that's 50 API calls, which is 1/3 of the hourly limit...
Is there a better way to do this?
Update:
I have requested whitelisting, and the guys at Twitter told me I should instead use the new Streaming API.
This kinda sucks since it's in Alpha testing, and the documentation is unclear, but the concept looks cool, and the limits are different than the regular API. Gonna dive into it later.
Only reliable user information you can get from twitter search results are username (from_user) and profile image url. If you want more information, you will have to call the users/show method for each user. There is no workaround or better way(that I'm aware of).
You will have to Cache user information and request whitelisting.

What is the number in a twitter status update URL?

My latest Twitter status update has the URL http://twitter.com/dinomite/status/1743967905 Does anyone know if there is any rhyme or reason behind the number 1743967905? It looks to me as though it might be a sequentially-assigned number for all Twitter users; I certainly haven't update 1.7b times, but all of Twitter might be around that. Anyone know?
According to the Twitter API docs it is the numerical ID of the status. I'd guess it's unique and sequential across all users, but I don't know for sure. If you need to know more take a look here for the official docs.
That would probably be the primary key in the status table. That URL format is used to look at a specific tweet.
Note that http://twitter.com/dinomite is the actual feed.
Also, based on how it seems to grow incrementally, this is probably an IDENTITY column or similar.
Yes, they're sequential.
One of the things it's helpful for is when writing a Twitter client, you can ask for anything newer than the last number you're already seen, so that you don't get and have to parse duplicates.

Resources