0

Hey All I'm developing a java desktop application. I have to search tweets by hashtags using twitter4j 3.0.5. I' have no problem with authentication and searching for tweets but there are some problems: I've tested my search results with topsy.com and i've seen that i get few tweets or no tweets. like #jobbingfest have about 500 tweets, but i found it empty... An intrest thing: the Twitter.search(query) docs say

Returns tweets that match a specified query. This method calls http://search.twitter.com/search.json

that api return a json like this

{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}

I'm little bit confused... why i'm able to get tweets if that resource is no longer available?

I'm trying to understand the problem, but no way... i had to write here for help :p.

Thanks a lot! Licio.

ps. sorry but maybe my english isn't so good...

pps. to retrieve more than 100 tweets i use to do this is correct?

List<MioStatus> listaStatus = null;
try {
    listaStatus = new ArrayList<MioStatus>();
    result = twitter.search(query);
    while(result.nextQuery() != null){
        for (Status status : result.getTweets()) {
            if(status.isRetweet()){
                listaStatus.add(new MioStatus(status.getId(), true, "RT " + status.getRetweetedStatus().getText(), status.getUser(), status.getGeoLocation(), status.getRetweetCount(), status.getCreatedAt()));
            }else{
                listaStatus.add(new MioStatus(status.getId(), true, status.getText(), status.getUser(), status.getGeoLocation(), status.getRetweetCount(), status.getCreatedAt()));
            }
         }
         result = twitter.search(result.nextQuery());
    }
0pipe0
  • 17
  • 5
  • http://stackoverflow.com/questions/17887984/is-it-possible-to-get-more-than-100-tweets/25069446#25069446 please see 5th comment its very useful :) – A Qadeer Qureshi Jul 31 '14 at 21:46

2 Answers2

0

The Twitter REST API v1 is no longer active. You can't work with that to get tweeter's data. From the site:

Version 1 of the REST API is now deprecated and will cease functioning in the coming months. Migrate to version 1.1 today.

However , API 1.1 supports JSON only, dropping XML, Atom and RSS support.

Again in your code, you are calling nextQuery() twice in the following fragmentation (read the comments):

    while(result.nextQuery() != null){   // you are calling nextQuery() but 
                                   //you should call hasNext() boolean check
        for (Status status : result.getTweets()) {
            // do whatever you were doing

         }
         result = twitter.search(result.nextQuery()); 
                    // you are calling nextQuery() here, so no need to call 
                  //in while conditional check
       } // while ends here
Sage
  • 15,290
  • 3
  • 33
  • 38
  • yes you're right! But: 1) twitter4j is api 1.1 compatible 2) i haven't problems to get tweets - not at all. – 0pipe0 Oct 12 '13 at 19:42
  • Oh... great! haven't seen the hasNext()... -.- thnx – 0pipe0 Oct 13 '13 at 08:00
  • mmmm searching about getting tweets i found this http://www.brightplanet.com/2013/06/twitter-firehose-vs-twitter-api-whats-the-difference-and-why-should-you-care/ ... maybe the problem is in search api. I have to use stream api. I'll try... – 0pipe0 Oct 13 '13 at 08:53
0

ok i get something... Just changed the assignation of twitter like that

Twitter twitter = TwitterFactory.getSingleton();

Don't ask me why, i'm using mvc and should be the same saving an instance in a map, but... Now the problem is ... "Where are old tweets??" setting setSince() is useless. Twitter limitations?

0pipe0
  • 17
  • 5