当前位置: 首页>>代码示例>>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;未经允许,请勿转载。