当前位置: 首页>>代码示例>>C#>>正文


C# TwitterService.Search方法代码示例

本文整理汇总了C#中TweetSharp.TwitterService.Search方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.Search方法的具体用法?C# TwitterService.Search怎么用?C# TwitterService.Search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TweetSharp.TwitterService的用法示例。


在下文中一共展示了TwitterService.Search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search

        public List<TwitterStatus> Search(TwitterService service, string categoria)
        {
            
            try
            {
                var tweets = service.Search(new SearchOptions {Q = categoria, Count = 200});
                List<TwitterStatus> tw = tweets.Statuses.Where(tweet => tweet.Id > 0).ToList();

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                tweets =
                    service.Search(new SearchOptions {Q = categoria, Count = 200, MaxId = tweets.Statuses.Last().Id});
                tw.AddRange(tweets.Statuses.Where(tweet => tweet.Id > 0));

                return tw;
            }

            catch (Exception exception)
            {
                throw exception;
            }
        }
开发者ID:thiagopaivamed,项目名称:Crawler,代码行数:52,代码来源:TwitterServiceRepository.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            tweetsUserName = new List<PuzzleData>();
            TwitterService service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);

            var options = new SearchOptions { Q = "Brilliant @fredtrotter post about bitcoin, Wall Street, and cancer http://t.co/q9WZNA0cZR) Must read on \"malignant computation\"!", Count =30 };
            TwitterSearchResult tweets = service.Search(options);

            int i = 0;

            foreach (var tweet in tweets.Statuses)
            {
                authorUrl = tweet.RetweetedStatus.User.ProfileImageUrlHttps;
                if (authorUrl.Contains(".png") || authorUrl.Contains(".jpg") || authorUrl.Contains(".bmp"))
                {
                    authorUrl = authorUrl.Remove(authorUrl.Length - 11, 7);
                }
                else if (authorUrl.Contains(".jpeg"))
                {
                    authorUrl = authorUrl.Remove(authorUrl.Length - 12, 7);
                }
                i += 1;
                if (i > 10) break;

                tweetsUserName.Add(new PuzzleData() { followerCount = tweet.User.FollowersCount, profileImage = tweet.User.ProfileImageUrl, userId = tweet.User.Id });

            }
            tweetsUserName = tweetsUserName.OrderByDescending(x => x.followerCount).ToList();
        }
开发者ID:KnightOfProblems,项目名称:PuzzleSolver,代码行数:30,代码来源:PuzzleSolver.aspx.cs

示例3: GetSocialInfomation

        public IQueryable<DisplayItem> GetSocialInfomation(string name)
        {
            IQueryable<DisplayItem> items = null;

            try
            {
                var twitterClientInfo = new TwitterClientInfo();
                twitterClientInfo.ConsumerKey = SettingsHelper.ConsumerKey;
                twitterClientInfo.ConsumerSecret = SettingsHelper.ConsumerSecret;

                var twitterService = new TwitterService(twitterClientInfo);
                twitterService.AuthenticateWith(SettingsHelper.AccessToken, SettingsHelper.AccessSecret);
                var searchOptions = new SearchOptions
                {
                    Q = name,
                };

                var searchResults = twitterService.Search(searchOptions);
                items = searchResults.Statuses.Select(x => ConvertToDataItem(x)).AsQueryable();
            }
            catch(Exception ex)
            {
                Logger.Error(ex);
            }

            return items;
        }
开发者ID:jondjones,项目名称:HackDays,代码行数:27,代码来源:TwitterConnector.cs

示例4: Search

        public SearchResultWithRateLimit Search(string query, long sinceid, TwitterApp keys)
        {
            var service = new TwitterService(keys.ConsumerKey, keys.ConsumerKeySecret);
            service.AuthenticateWith(keys.Token, keys.TokenSecret);
            var options = new SearchOptions
            {
                Q = System.Web.HttpUtility.UrlEncode(query),
                Count = 100,
                Lang = "en",
                Resulttype = TwitterSearchResultType.Mixed,
                SinceId = sinceid
            };

            // Geocode = new TwitterGeoLocationSearch(39.6456, -79.9433, 30, TwitterGeoLocationSearch.RadiusType.Mi),

            var result = new SearchResultWithRateLimit();
            result.SearchResult = service.Search(options);
            result.RateLimitStatus = service.Response.RateLimitStatus;
            if (result.SearchResult.Statuses.Any())
            {
                result.LastId = result.SearchResult.Statuses.OrderByDescending(f => f.Id).FirstOrDefault().Id;
            }
            else
            {
                result.LastId = sinceid;
            }

            return result;
        }
开发者ID:jdehlin,项目名称:Twitta,代码行数:29,代码来源:TwitterSearchRepository.cs

示例5: MainPage

        public MainPage()
        {
            InitializeComponent();
            message = messageResult;
            var service1 = new TwitterService("6V1TS5zCiVwkQxUDODCdHA24a", "hAxb6eEht6TMVxFoXT8aOz65UY4CNCQzrwVV1UvKvJBBE9qO6o");
            service1.AuthenticateWith("3004303633-XafkiZvVq8KTfk0hPusedUwPSQsjiE9c49D4WRZ", "Rjg811qZJnZDaAY9ncdHKxz0ZpuUJNvPtkxinXqv43Qiq");

            service1.Search(new SearchOptions { Q = "#OpenHack2015" }, message);
        }
开发者ID:KerwinMa,项目名称:KnowYourEvent,代码行数:9,代码来源:MainPage.xaml.cs

示例6: SaveTweets

        private void SaveTweets(UserQuery query)
        {
            if (!String.IsNullOrWhiteSpace(query.Accounts) && !String.IsNullOrWhiteSpace(query.Hashtags))
            {
                var tweetHistoryClient = new Components.TableStorageClient<TweetHistory>(TweetHistory.TableName);
                var retweetHistoryClient = new Components.TableStorageClient<RetweetHistory>(RetweetHistory.TableName);

                string users = "from:@" + query.Accounts.Replace(" ", " OR from:@");
                string hashtags = "#" + query.Hashtags.Replace(" ", " OR #");

                TwitterService service = new TwitterService();

                var tweetsearch = service.Search(users + " AND " + hashtags);
                if (tweetsearch != null)
                {
                    int counter = 1;
                    foreach (var tweet in tweetsearch.Statuses.Take(5))
                    {
                        Trace.WriteLine(String.Format("Processing message {0}: {1}", tweet.Id, tweet.Text));
                        tweetHistoryClient.Upsert(new TweetHistoryLimited
                        {
                            Author = tweet.Author.ScreenName,
                            Created = tweet.CreatedDate,
                            PartitionKey = TweetHistory.GetPartitionKey(query.RowKey),
                            RowKey = tweet.Id.ToString(),
                            Text = tweet.Text,
                            TextAsHtml = tweet.TextAsHtml
                        });

                        if (counter % 100 == 0)
                            tweetHistoryClient.SaveChanges();

                        var retweets = retweetHistoryClient.CreateQuery().Where(o => o.PartitionKey == query.PartitionKey && o.RowKey == tweet.Id.ToString()).ToList();
                        if (!retweets.Any())
                        {
                            Trace.WriteLine("Retweeting: " + tweet.Id + " - " + tweet.Text);

                            service.AuthenticateWith("uzCIaghLdrhr0no5FofcxA", "ext0Y58028clVZqd6glR25JmxKL3nGzPzLyAESMHVY", "596423606-R4coIeOUigAWlRKe3jiSXjf4mlyTNnuKd12fxNWX", "4vQkaTFC138wU7UeVCck4hHPyvABPLF2WaI2huLFDU");

                            if (tweet.Text.Length > 120)
                                tweet.Text = tweet.Text.Substring(0, 120);

                            service.SendTweet("#was12 - " + tweet.Text);

                            retweetHistoryClient.Insert(new RetweetHistory()
                            {
                                PartitionKey = query.PartitionKey,
                                RowKey = tweet.Id.ToString()
                            });
                            retweetHistoryClient.SaveChanges();
                        }
                    }

                    tweetHistoryClient.SaveChanges();
                }
            }
        }
开发者ID:FredDotNet,项目名称:TwiBo,代码行数:57,代码来源:WorkerRole.cs

示例7: GetTweetsFromPhrase

 public string GetTweetsFromPhrase(String phrase)
 {
     var service = new TwitterService(consumerKey, consumerSecret);
     service.AuthenticateWith(accessToken, accessTokenSecret);
     SearchOptions so = new SearchOptions();
     so.Q = phrase;
     so.Count = 100;
     var tweeting = service.Search(so);
     IEnumerable<TwitterStatus> returnValue = tweeting.Statuses;
     TweetsInst tweets = null;
     MulTweetInstance multweets = new MulTweetInstance();
     foreach (var twt in returnValue)
     {
         tweets = new TweetsInst();
         if (twt.Author.ScreenName != null)
         {
             tweets.author = twt.Author.ScreenName;
         }
         else { tweets.author = ""; }
         if (twt.Author.ProfileImageUrl != null)
         {
             tweets.UserImage = twt.Author.ProfileImageUrl;
         }
         else { tweets.UserImage = ""; }
         if (twt.User != null)
         {
             tweets.User_ID = Convert.ToString(twt.User.Id);
         }
         else { tweets.User_ID = null; }
         if (twt.Text != null)
         {
             tweets.tweet = twt.Text;
         }
         else { tweets.tweet = ""; }
         if (twt.Location != null)
         {
             tweets.latitude = Convert.ToString(twt.Location.Coordinates.Latitude);
         }
         else { tweets.latitude = ""; }
         if (twt.Location != null)
         {
             tweets.longitude = Convert.ToString(twt.Location.Coordinates.Longitude);
         }
         else { tweets.longitude = null; }
         if (twt.Place != null)
         {
             tweets.country = twt.Place.Country;
         }
         else { tweets.country = ""; }
         multweets.mulTweet.Add(tweets);
     }
     string output = JsonConvert.SerializeObject(multweets);
     return output;
 }
开发者ID:ksm5629,项目名称:WebServices,代码行数:54,代码来源:Service.cs

示例8: DisplayTweetList

        public void DisplayTweetList()
        {
            if (CheckNetwork() == true)
            {
                MessageBox.Show("A network connection can not be established.\r\nPlease press refresh or check your network settings.");
                return;
            }
            else
            {
                resultListBox.ItemsSource = "";

                TwitterService service = new TwitterService("W0b46KugjRZXjYNSxt1w", "lC4zTfoSsOlWRtfmXVfuSWS9KNKKfWLValqjFN1u4");
                service.AuthenticateWith("750912427-zEW7TYdGoswu3AzpCUPlD3rZsUc9HMXYJkKzrVR8", "7FBXTf2Xyihe0DLV4L97COGvgdVhQajE1ixM02Bw0");

                service.Search("#" + App.selectedCountryDetails.CountryLongName, (results, response) =>
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        resultListBox.Dispatcher.BeginInvoke(new Action(delegate()
                        {  // Add data to listbox(name=resultList)
                            //resultList.Items.Add(response.StatusDescription); //To know whether request succeed
                            // showResults.Text = response.RequestUri + results.RawSource;// Json file is here.
                            // resultList.Items.Add(response.Response);
                            //TwitterSearch.Result result = new TwitterSearch.Result();
                            //var deserializedJSON = JsonConvert.DeserializeObject<TwitterSearch.tResult>(results.RawSource);
                            //resultList.Items.Add(response.RequestUri);  //Sent query url
                            string resultString = results.RawSource.ToString();
                            RootObject1 tresult = JsonConvert.DeserializeObject<RootObject1>(resultString);
                            if (tresult.results.Count == 0)
                            {
                                tResult empty = new tResult();
                                empty.text = "Sorry,No Result was found";
                                empty.profile_image_url = "https://twimg0-a.akamaihd.net/profile_images/2284174758/v65oai7fxn47qv9nectx_normal.png";
                                tresult.results.Add(empty);
                                resultListBox.ItemsSource = tresult.results;
                            }
                            else
                            {
                                resultListBox.ItemsSource = tresult.results;
                            }
                        }));

                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(new Action(delegate()
                        {
                            MessageBox.Show("An error occured. Please exit app and try again.\r\nError Details: " + response.StatusCode.ToString());

                        }));
                    }
                });
            }
        }
开发者ID:Chengxuan,项目名称:BThere,代码行数:54,代码来源:TSearch.xaml.cs

示例9: GetTweetsByHashTagAsync

 public void GetTweetsByHashTagAsync(string hashTag)
 {
     var twitterService = new TwitterService();
     var result = twitterService.Search(hashTag,
         (tweets, response) =>
         {
             if (response.StatusCode == HttpStatusCode.OK)
             {
                 OnTweetSearchResultRetrieved(new TwitterSearchResultEventArgs() { TwitterSearchStatuses = tweets.Statuses });
             }
         });
 }
开发者ID:SparklingSoftware,项目名称:ALM-Community---DotNet-Unit-Testing-Framework-Comparision,代码行数:12,代码来源:TwitterFacade.cs

示例10: GetTweetsByHashTag

 //Syncronous
 public IEnumerable<TwitterSearchStatus> GetTweetsByHashTag(string hashTag)
 {
     //To get the consumer key and consumer secret, create an app via hhtp://dev.twitter.com
     var twitterService = new TwitterService("ocLgiNzqasrM6eq6rOTmw",
                                             "lLT8nzQoWZbdjYDWGnjmzoiA7BTlaLHe8vRFH4JwiY0",
                                             "22595957-0agngUCx0DnuzGxiovlEpYJvdmUxO8pSraqUpbZn8",
                                             "3jYeMHhWXstAvooatZOZBEmLHBnxGQv32FpVSBjuZk");
     var result = twitterService.Search(hashTag);
     if (result != null)
     {
         return result.Statuses;
     }
     return null;
 }
开发者ID:SparklingSoftware,项目名称:ALM-Community---DotNet-Unit-Testing-Framework-Comparision,代码行数:15,代码来源:TwitterFacade.cs

示例11: getTweetsByQuery

        /// <summary>
        /// Retrieves tweets for the given query
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public string getTweetsByQuery(string query)
        {
            try
            {
                TwitterService twitterService = new TwitterService();
                TwitterSearchResult twitterSearchResult = twitterService.Search(query);

                return JsonConvert.SerializeObject(twitterSearchResult);
            }
            catch
            {
                throw;
            }
        }
开发者ID:smartek,项目名称:POC,代码行数:19,代码来源:TwitterClient.cs

示例12: Main

        static void Main(string[] args)
        {
            string _consumerKey = "JXTOavtgUIN3ucDNRX3qsG5HM",
                _consumerSecret = "zf7szYPlnz4RG4utTsHnQRrreye4aNDoj8SNw6yiuklG9roDaj",
                _accessToken = "65598981-Hbx6HVVi1prAkW1MkzhBEw8oX2vNTti1UMK4BAAiS",
                _accessTokenSecret = "yuQWecLhU5GqBUgdhysiJm7hbBGLCnmTNEInZvu5xOiiF";
            var service1 = new TwitterService(_consumerKey, _consumerSecret);
            service1.AuthenticateWith(_accessToken, _accessTokenSecret);

            var block = new AutoResetEvent(false);
            TwitterStatus[] searchResult = new TwitterStatus[0];

            service1.Search(new SearchOptions() { Q = ":)", Count = 20, IncludeEntities = true, Lang = "en" }, (result, respone) =>
            {
                Console.WriteLine("On going...");
                HttpStatusCode code = respone.StatusCode;

                if (code == HttpStatusCode.OK)
                {
                    searchResult = new TwitterStatus[result.Statuses.Count()];
                    result.Statuses.ToList().CopyTo(searchResult);
                    block.Set();
                }
            });

            //TwitterRateLimitStatus rate = service1.Response.RateLimitStatus;
            //Console.WriteLine("You have used " + rate.RemainingHits + " out of your " + rate.HourlyLimit);

            Console.WriteLine("Out going...");
            block.WaitOne();
            service1.CancelStreaming();
            if (searchResult.Count() > 0)
            {
                WebClient webClient = new WebClient();
                StreamWriter writer = new StreamWriter("out.txt");
                for (int i = 0; i < searchResult.Count(); i++){
                    var photo = searchResult[i].Entities.Media.FirstOrDefault(m => m.MediaType == TwitterMediaType.Photo);
                    string attachedPhoto = "-";
                    if (photo != null)
                    {
                        attachedPhoto = "O";
                        webClient.DownloadFile(photo.MediaUrl, searchResult[i].Id + ".jpg");
                    }
                    string s = searchResult[i].Id + "\t" + attachedPhoto + "\t" + searchResult[i].User.ScreenName + "\t" + searchResult[i].Text;
                    writer.WriteLine(s);
                }
                writer.Close();
            }
            Console.WriteLine("Finish");
        }
开发者ID:huynq9,项目名称:MS_TwitterSentimentAnalysis,代码行数:50,代码来源:GetTweetData.cs

示例13: Index

        public ActionResult Index()
        {
            string consumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"];
            string consumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"];
            //TwitterService("Consumer Key", "Consumer Secret");
            var service = new TwitterService(consumerKey, consumerSecret);

            //AuthenticatedWith("Access Token", "AccessTokenSecret");
            service.AuthenticateWith("486817944-yhSED5Ysl9QIMHcBtytpxzQizupSftTNGbaxZlEV", "XjLnM06gky1r7pZnLhQCB2uu052qkUatkVqgR7yGvQEne");

            //ScreenName="Screen Name", Count=Number of Tweets /www.twitter.com/screenname.
            IEnumerable<TwitterStatus> tweetsByHandle = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = "kare11", Count = 5 });
            //IEnumerable<TwitterStatus> tweetsByHandle = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = "HFBoysLax", Count = 5 });
            TwitterSearchResult tsr = service.Search(new SearchOptions { Q = "Paris", Count = 5 });
            IEnumerable<TwitterStatus> tweetsByHashTag = tsr.Statuses;
            IEnumerable<TwitterStatus> tweets = tweetsByHandle.Concat(tweetsByHashTag);

            ViewBag.Tweets = tweets.OrderByDescending(CreatedDate => CreatedDate);
            return View();
        }
开发者ID:livy036,项目名称:MCLC,代码行数:20,代码来源:HomeController.cs

示例14: bw_DoWork

        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            TwitterService service = new TwitterService(TwitterSettings.ConsumerKey, TwitterSettings.ConsumerSecret);
            service.AuthenticateWith(TwitterSettings.AccessToken, TwitterSettings.AccessTokenSecret);

            TwitterSearchResult results = service.Search(searchTextBox.Text, Convert.ToInt16(e.Argument)); // max 1500 / 100 per page

            /* need to check for errors here, got a 503 "services overloaded" today */

            if (results.Statuses.Count() > 0)
            {
                tweets = new List<TwitterSearchStatus>(results.Statuses);
                UpdateTweetGroupBox("Tweet 1 / " + tweets.Count.ToString());
                ShowTweet(tweets[0]);

                e.Result = tweets.Count;
            }
            else
            {
                e.Result = null;
            }
        }
开发者ID:SpikedCola,项目名称:twitply,代码行数:22,代码来源:Main.cs

示例15: Results

        public ActionResult Results(string Q)
        {
            // Set up your credentials
            String _consumerKey         = ConfigurationManager.ConnectionStrings["TWITTER_CONSUMER_KEY"].ConnectionString;
            String _consumerSecret      = ConfigurationManager.ConnectionStrings["TWITTER_CONSUMER_SECRET"].ConnectionString;
            String _accessToken         = ConfigurationManager.ConnectionStrings["TWITTER_ACCESS_TOKEN"].ConnectionString;
            String _accessTokenSecret   = ConfigurationManager.ConnectionStrings["TWITTER_ACCESS_TOKEN_SECRET"].ConnectionString;

            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith( _accessToken, _accessTokenSecret);

            var result = service.Search(
                new SearchOptions{
                    Q = Q,
                    Lang = "nl",
                    Count = 10
                }
            );

            ViewBag.Q = Q;
            ViewBag.Tweets = result.Statuses;
            return View();
        }
开发者ID:relaxnow,项目名称:TweetSentNL,代码行数:23,代码来源:SearchController.cs


注:本文中的TweetSharp.TwitterService.Search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。