當前位置: 首頁>>代碼示例>>C#>>正文


C# TwitterService.SearchForUser方法代碼示例

本文整理匯總了C#中TweetSharp.TwitterService.SearchForUser方法的典型用法代碼示例。如果您正苦於以下問題:C# TwitterService.SearchForUser方法的具體用法?C# TwitterService.SearchForUser怎麽用?C# TwitterService.SearchForUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TweetSharp.TwitterService的用法示例。


在下文中一共展示了TwitterService.SearchForUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetFavorites

        public IEnumerable<TwitterStatus> GetFavorites()
        {
            var service = new TwitterService(Config.Twitter.ConsumerKey, Config.Twitter.ConsumerSecret);

            // Step 1 - Retrieve an OAuth Request Token
            var requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            var uri = service.GetAuthorizationUri(requestToken);
            Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token
            Console.Write("Please, your key? ");
            var verifier = Console.ReadLine(); // <-- This is input into your application by your user
            var access = service.GetAccessToken(requestToken, verifier);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);

            var users = service.SearchForUser("kellogh");
            if (users == null)
            {
                Console.WriteLine("No users found");
                yield break;
            }

            var user = users.First();

            var favorites = service.ListFavoriteTweetsFor(user.Id);

            foreach (var tweet in favorites)
            {
                yield return tweet;
            }
        }
開發者ID:tkellogg,項目名稱:TweetDigest,代碼行數:35,代碼來源:TwitterHelpers.cs

示例2: Post

        public HttpResponseMessage Post([FromUri]int Id, [FromUri]bool ArtistPost)
        {
            Proposal currProposal =  _db.Proposal.FirstOrDefault(c=>c.Id == Id);
               Models.Service service = _db.User.FirstOrDefault(c => c.UserId == WebSecurity.CurrentUserId).Services.FirstOrDefault(c=>c.Provider == "twitter");

               if (service != null)
               {

                   TwitterService twitter = new TwitterService(Settings.Settings.TwitterConsumerKey, Settings.Settings.TwitterConsumerSecret, service.Token, service.TokenSecret);
                   try
                   {
                       if (ArtistPost == true)
                       {
                           //string message = "test message";
                           var result = twitter.SearchForUser(currProposal.Artist).ToList();

                           string message = "@" + result[0].Name.Replace(" ",string.Empty) + " It was suggested tha you play an event at " + currProposal.Venue + " for more info go to www.botf.azurewebsites.net";
                           twitter.SendTweet(message);

                       }
                       else
                       {

                           string message = "just suggested the event " + "->"
                              + currProposal.Artist + "<-" + " at " + "->" + currProposal.Venue + "<-" + "." + " Like this? Get on board! at " + System.Web.HttpContext.Current.Request.UrlReferrer.ToString();

                        twitter.SendTweet(message);

                       }

                       return Request.CreateResponse(HttpStatusCode.OK);
                   }
                   catch (Exception)
                   {

                       return Request.CreateResponse(HttpStatusCode.Conflict);
                   }
               }
               else
               {
                   return Request.CreateResponse(HttpStatusCode.BadRequest);

               }
        }
開發者ID:msanj1,項目名稱:BOTF,代碼行數:44,代碼來源:TwitterProposalController.cs


注:本文中的TweetSharp.TwitterService.SearchForUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。