0

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?

Fake Man
  • 271
  • 1
  • 3
  • 8

2 Answers2

0

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.

mgokhanbakal
  • 1,679
  • 1
  • 20
  • 26
  • It means I have to add location of every American city. Which is quite frustrating. So I decided to take all English tweets and filter them when they come. – Fake Man Dec 23 '13 at 16:21
  • I did not mean that you should add all location info for each city in the USA. I meant that may be you can apply a trick something like you can add as pairs of longitude and latitude data of the USA borders. Of course, adding each city is silly. Also, if you look at my previous reply, I shared the links and said you can look at those links for any solution, but you understood adding every city manually. However; I understood that you can add some location info as a boundary. Anyway, I hope you can figure out that. – mgokhanbakal Dec 23 '13 at 16:45
0

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:

enter image description here

Or just create longer boolean that does what you want..

geotheory
  • 22,624
  • 29
  • 119
  • 196