예제 #1
0
        public static void AdvancedSearch(AdvancedSearchParam criterion, ref ObservableCollection<TwitterStatus> tweets)
        {
            tweets.Clear();
            //TwitterResult response;
            //if (criterion.Distance != 0 && criterion.GeoLocation != null)
            //    response = FluentTwitter.CreateRequest()
            //        .Search().Query().ContainingHashTag(criterion.Tag)
            //        .Containing(criterion.AnyWords).NotContaining(criterion.WithoutWords)
            //        .InLanguage(criterion.Language).Within(criterion.Distance).Of(criterion.GeoLocation)
            //        .AsJson().Request();
            //else
            //    response = FluentTwitter.CreateRequest()
            //        .Search().Query().ContainingHashTag(criterion.Tag)
            //        .AddNotContainingWords(criterion.WithoutWords).Containing(criterion.AnyWords)
            //        .InLanguage(criterion.Language)
            //        .AsJson().Request();

            var service = new TwitterService();
            service.AuthenticateWith(Settings.Default.ConsumerKey,
                            Settings.Default.ConsumerSecret,
                            Model.OAuthHandler.Token,
                            Model.OAuthHandler.TokenSecret);
            TwitterSearchResult results = service.SearchForTweets(criterion.ToString(), 1, 40);
            if (results == null)
                return;

            //ValidateResponse(response);
            //TwitterSearchResult results = response.AsSearchResult();

            foreach (TwitterStatus status in results.Statuses)
            {
                tweets.Add(status);
            }
        }