twitter4j how to get only statuses with location data from a twitter stream

后端 未结 2 752
-上瘾入骨i
-上瘾入骨i 2021-01-07 13:27

I\'m getting high numbers of \"onTrackLimitationNotice\". I\'d like to narrow my predicate by only searching for statuses with geo location, but all geo locations? Can this

相关标签:
2条回答
  • 2021-01-07 13:49

    i found that querying the stream for a global bounding box, returns only status withs geo location. So this worked:

    // cb is an instace of ConfigurationBuilder
    TwitterStream twitter = new TwitterStreamFactory(cb.build()).getInstance();
    FilterQuery filtro = new FilterQuery();    
    double[][] bb= {{-180, -90}, {180, 90}};
    filtro.locations(bb);
    twitter.addListener(listener);
    twitter.filter(filtro);
    

    returning only tweets with location info.

    0 讨论(0)
  • 2021-01-07 13:55

    Not an answer but a Simple workaround:

    I know most of people don't have GPS enabled when they tweet and others would not like to share their location!

    But they are still sharing their location!! Guess how? On their profiles! Their hometown, their country is mostly visible, which can give you an approximate location of where the tweet came from! You can query for the user's profile and thus his/her location using the Rest API

    twitter.showUser(userScreenName).getLocation();

    0 讨论(0)
提交回复
热议问题