Search code examples
androidtwittertwitter-fabric

Fabric Twitter Kit


Can anyone please explain me the meaning of the following line of code? I mean how it works.

 final SearchService service = Twitter.getApiClient().getSearchService();
service.tweets(Search_query,null, lang,null,Search_result_type,Search_count,null,null,null,true, new Callback<Search>() {......}

I read the fabric docs and there it was written getSearchService() is a method of TwitterApiClient class. But whenever I am trying to use TwitterApiClient to access getSearchService(), its not showing the getSearchService() method. But using the above code,i.e., Twitter.getApiClient().getSearchService(), it works. Can anyone explain me each and every word of the Code that I have provided ?


Solution

  • This is method of TwitterApiCllient use following link :  
    https://docs.fabric.io/javadocs/twittercore/1.3.4/com/twitter/sdk/android/core/TwitterApiClient.html
    
    parameter you pass inside method tweet has following means :    
    tweets(query,geocode,lang,locale,resultType,count,until,sinceId, maxId, includeEntities, Callback<Search> cb) 
    follow this link :
    https://docs.fabric.io/javadocs/twittercore/1.3.4/com/twitter/sdk/android/core/services/SearchService.html 
    
    by default this api show only last 7 days tweet for exact query which you search
    
    Use like this :
    private void loadTweets() {
    
    
    final SearchService service = Twitter.getApiClient().getSearchService();
    service.tweets(SEARCH_QUERY, null, null, null, SEARCH_RESULT_TYPE, SEARCH_COUNT, null, null,
            maxId, true, new Callback<Search>() {
                @Override
                public void success(Result<Search> searchResult) {
    
    
                }
    
                @Override
                public void failure(TwitterException error) {
    
    
                }
            }
    );