• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# TweetSharp.TwitterService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TwitterService类属于TweetSharp命名空间,在下文中一共展示了TwitterService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ProcessAuthoriztion

        public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
        {
            var twitterService = new TwitterService(KeyStorage.Get("twitterKey"), KeyStorage.Get("twitterSecret"));

            if (String.IsNullOrEmpty(context.Request["oauth_token"]) ||
                String.IsNullOrEmpty(context.Request["oauth_verifier"]))
            {
                var requestToken = twitterService.GetRequestToken(context.Request.Url.AbsoluteUri);

                var uri = twitterService.GetAuthorizationUri(requestToken);

                context.Response.Redirect(uri.ToString(), true);
            }
            else
            {
                var requestToken = new OAuthRequestToken { Token = context.Request["oauth_token"] };
                var accessToken = twitterService.GetAccessToken(requestToken, context.Request["oauth_verifier"]);
                twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

                var user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

                return ProfileFromTwitter(user);
            }

            return new LoginProfile();

        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:27,代码来源:TwitterLoginProvider.cs


示例2: bw_DoWork

        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            TwitterService service = new TwitterService(consumerKeyTextBox.Text, consumerSecretTextBox.Text, accessTokenTextBox.Text, accessTokenSecretTextBox.Text);

            TwitterUser user = service.VerifyCredentials();

            if (service.Response.InnerException != null)
            {
                TwitterError error = service.Deserialize<TwitterError>(service.Response.Response);
                if (!string.IsNullOrEmpty(error.ErrorMessage))
                {
                    e.Result = error; // return the error object on failure
                }
                else
                {
                    e.Result = null; // err, dunno. return null
                }
            }
            else if (user != null)
            {
                e.Result = user; // return user object on success
            }
            else
            {
                e.Result = null; // unknown error
            }
        }
开发者ID:SpikedCola,项目名称:twitply,代码行数:27,代码来源:Settings.cs


示例3: GetAuthenticatedService

 public TwitterService GetAuthenticatedService()
 {
     var twitterClientInfo = new TwitterClientInfo {ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret};
     twitterService = new TwitterService(twitterClientInfo);
     twitterService.AuthenticateWith(AccessToken, AccessTokenSecret);
     return twitterService;
 }
开发者ID:kejto,项目名称:TweetApp,代码行数:7,代码来源:TwitterServiceBase.cs


示例4: LoadTweets

        public static IReadOnlyCollection<PoliticalTweet> LoadTweets( IEnumerable<string> handles )
        {
            var service = new TwitterService( ConsumerKey, ConsumerSecret );
            service.AuthenticateWith( AccessToken, AccessTokenSecret );
            var results = new List<PoliticalTweet>();

            foreach ( var handle in handles.Distinct() )
            {
                try
                {
                    var response = service.ListTweetsOnUserTimeline( new ListTweetsOnUserTimelineOptions
                    {
                        ScreenName = handle,
                        Count = 200,
                        IncludeRts = false,
                        ExcludeReplies = true
                    } );
                    results.AddRange( response.Select( t => new PoliticalTweet( handle, t.Text, t.CreatedDate, t.IdStr ) ) );

                    Debug.WriteLine( $"{service.Response.RateLimitStatus.RemainingHits} remaining hits." );
                    if ( service.Response.RateLimitStatus.RemainingHits <= 0 )
                    {
                        var wait = service.Response.RateLimitStatus.ResetTime.ToUniversalTime() - DateTime.UtcNow;
                        Debug.WriteLine( $"Rate limit reached. Sleeping for {wait}." );
                        Thread.Sleep( wait );
                    }
                }
                catch
                {
                    Debug.WriteLine( $"Skipping {handle}" );
                }
            }

            return results;
        }
开发者ID:PoliTweets,项目名称:importer,代码行数:35,代码来源:TweetsImporter.cs


示例5: ReturnFromTwitter

        // This URL is registered as the application's callback at http://dev.twitter.com
        public ActionResult ReturnFromTwitter(string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauth_token };

            // Step 3 - Exchange the Request Token for an Access Token
            string _consumerKey = System.Configuration.ConfigurationManager.AppSettings["consumerKeyLogin"];
            string _consumerSecret = System.Configuration.ConfigurationManager.AppSettings["consumerSecretLogin"];
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

            string TwitterToken = accessToken.Token;
            string TwitterToeknSecret = accessToken.TokenSecret;
            Session[Sessionvars.TwitterRequestToken] = TwitterToken;  //You can save this token in your database for pulling user's data in future. this will be save every time while getting permission
            Session[Sessionvars.TwitterRequestTokenSecert] = TwitterToeknSecret; //You can save this token in your database for pulling user's data in future. this will be save every time while getting permission
            ViewBag.TwitterToken = accessToken.Token;

            // Step 4 - User authenticates using the Access Token

            //service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            //TwitterUser user = service.VerifyCredentials();
            //var status = user.Status;
            //ViewBag.status = status;
            //ViewBag.UserName = user.Name;
            //ViewBag.location = user.Location;
            //ViewBag.count = user.FollowersCount;

            //TwitterDirectMessage Ds = service.SendDirectMessage(user.Id, "hi this test messages");
            //service.SendTweet("hi this is test from me at live");
            //service.SendTweet("msg", user.Id);
            //ViewBag.Userid = service.BeginFollowUserNotifications(user.Id);

            return RedirectToAction("Invite");
        }
开发者ID:emiprotech,项目名称:loginwithtwitter,代码行数:34,代码来源:HomeController.cs


示例6: Login

 public ActionResult Login(string returnUrl)
 {
     var service = new TwitterService(ConsumerKey, ConsumerSecret);
     var requestToken = service.GetRequestToken(Url.Action("LoginCallback", "Auth", new {returnUrl}, Request.Url.Scheme));
     var uri = service.GetAuthorizationUri(requestToken);
     return Redirect(uri.ToString());
 }
开发者ID:RomanGorgol,项目名称:nosql,代码行数:7,代码来源:AuthController.cs


示例7: Main

        public static void Main(string[] args)
        {
            var service = new TwitterService(consumerKey, consumerSecret);

            //			GetUserToken(service);
            ListenOnUserStream(service);
        }
开发者ID:mikehadlow,项目名称:socsnap,代码行数:7,代码来源:Main.cs


示例8: Main

        static void Main(string[] args)
        {
            TwangManSays("********************************************");
            TwangManSays("*             HANG THE TWANG               *");
            TwangManSays("********************************************");
            CurrentGames = new Dictionary<long, TwitterThread>();
            tweetsToSend = new ConcurrentQueue<SendArgs>();

           
            TwitterSender = new Task(DoWork);
            TwitterSender.Start();

            _sendService = new TwitterService(Authentication.ConsumerKey, Authentication.ConsumerSecret);
            _sendService.AuthenticateWith(Authentication.AccessToken, Authentication.AccessTokenSecret);

            _service = new TwitterService(Authentication.ConsumerKey, Authentication.ConsumerSecret);
            _service.AuthenticateWith(Authentication.AccessToken, Authentication.AccessTokenSecret);

            TwitterListener = new Task(Listen);
            TwitterListener.Start();


            Console.ReadLine();
            _service.CancelStreaming();
        }
开发者ID:justasitsounds,项目名称:TwitterHangman,代码行数:25,代码来源:Program.cs


示例9: GetUser

 public TwitterUser GetUser(LoginModel model)
 {
     var twitterService = new TweetSharp.TwitterService(ConsumerKey, ConsumerSecret);
     twitterService.AuthenticateWith(model.Token, model.Secret);
     TwitterUser user = twitterService.VerifyCredentials(new VerifyCredentialsOptions() { IncludeEntities = false, SkipStatus = false });
     return user;
 }
开发者ID:hafnis,项目名称:Sociopath,代码行数:7,代码来源:TwitterService.cs


示例10: Post

        public override void Post()
        {
            if ((String.IsNullOrEmpty(token = Config.TwitterAccessToken)
                || String.IsNullOrEmpty(tokenSecret = Config.TwitterTokenSecret))
                && !this.Auth())
            {
                App.Instance.AddError(Config.AUTHORIZATION_ERROR_EN, Config.TWITTER_TITLE);
                return;
            }
            else
            {
                //Authorize with the saved access token and secret
                TwitterClientInfo twitterClientInfo = new TwitterClientInfo();
                twitterClientInfo.ConsumerKey = ConsumerKey;
                twitterClientInfo.ConsumerSecret = ConsumerSecret;
                TwitterService twitterService = new TwitterService(twitterClientInfo);
                //twitterService.AuthenticateWith(token, tokenSecret);
            }

            try
            {
                this.PostTweet();
            }
            catch (Exception)
            {
                App.Instance.AddError(Config.TWITTER_ERROR, Config.TWITTER_TITLE);
            }
        }
开发者ID:ummterry,项目名称:Clipoff,代码行数:28,代码来源:TwitterUtility.cs


示例11: TweetViewModel

        public TweetViewModel(ITweetTimer tweetTimer, TwitterService service)
        {
            this.tweetTimer = tweetTimer;
            this.service = service;

            Tweets = new BindableCollection<Tweet>();
        }
开发者ID:silverforge,项目名称:TwitterClient,代码行数:7,代码来源:TweetViewModel.cs


示例12: ProcessAuthentication

        public Account ProcessAuthentication(string pin)
        {
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            OAuthAccessToken access = service.GetAccessToken(_requestToken, pin);

            service.AuthenticateWith(access.Token, access.TokenSecret);

            var profile = service.GetUserProfile();

            Account account = AccountManager.Instance.GetCurrentAccounts().Where(acc => acc.Username == profile.ScreenName).FirstOrDefault();
            if (account != null)
            {
                throw new AuthFailureException("User " +account.Username +  " already has an account with TweetOBox.");
            }
            if (profile != null && account == null)
            {
                account = new Account();
                account.Username = profile.ScreenName;
               // account.Password = profile.p
                account.AccountType = (int)AccountTypeEnum.Twitter;
                account.AccessToken = access.Token;
                account.AccessTokenSecret = access.TokenSecret;
                account.IsOAuth = true;
                AccountManager.Instance.AddAccount(account,false);
            }
            else
            {
                throw new AuthFailureException(service.Response.StatusDescription);
            }

            return account;
        }
开发者ID:ankitb,项目名称:TweetOBox,代码行数:33,代码来源:OAuth.cs


示例13: UploadPhoto

        /// 
        /// Uploads the photo and sends a new Tweet
        /// 
        /// <param name="binaryImageData">The binary image data.
        /// <param name="tweetMessage">The tweet message.
        /// <param name="filename">The filename.
        /// Return true, if the operation was succeded.
        public string UploadPhoto(string imageFile, string tpkey, string usrtoken, string usrsecret, string contoken, string consecret)
        {
            TwitterService service = new TwitterService(contoken, consecret);
            service.AuthenticateWith(usrtoken, usrsecret);

            Hammock.RestRequest request = service.PrepareEchoRequest();
            request.Path = "upload.xml";
            request.AddFile("media", "uploadfile", imageFile, "image/jpeg");
            request.AddField("key", tpkey);

            Hammock.RestClient client = new Hammock.RestClient() { Authority = "http://api.twitpic.com", VersionPath = "2" };
            Hammock.RestResponse response = client.Request(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                XDocument doc = XDocument.Parse(response.Content);

                XElement image = doc.Element("image");

                return image.Element("url").Value;
            }
            else
                throw new Exception("Error occured while uploading image to TwitPic servers. Please try again later");

            return "";
        }
开发者ID:ankitb,项目名称:TweetOBox,代码行数:33,代码来源:TwitPic.cs


示例14: Connect

        private void Connect(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
        {
            // In v1.1, all API calls require authentication
            var service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);

            Log("Connected");

            TwitterRateLimitStatusSummary rate = service.GetRateLimitStatus(new GetRateLimitStatusOptions());

            Log("Limimte rate: " + rate.RawSource);

            var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
            foreach (var tweet in tweets)
            {
                Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
            }

            TwitterCursorList<TwitterUser> friends = service.ListFollowers(new ListFollowersOptions());

            Log("Friends: " + friends.Count);

            foreach (var friend in friends)
            {
                Log(String.Format("Friend: {0}", friend.Name));
            }
        }
开发者ID:ludo6577,项目名称:TwitterBot,代码行数:27,代码来源:Form1.cs


示例15: TwitterWrapper

 public TwitterWrapper()
 {
     Service = new TwitterService(ConfigurationManager.AppSettings["consumerAccessorA"], ConfigurationManager.AppSettings["consumerAccessorB"]);
     Service.AuthenticateWith(ConfigurationManager.AppSettings["authTokenA"], ConfigurationManager.AppSettings["authTokenB"]);
     // Ha. I hope you don't use your Twitter account for anything else, Ryan...
     Service.IncludeRetweets = true;
 }
开发者ID:eedrah,项目名称:whatwouldroddo,代码行数:7,代码来源:TwitterWrapper.cs


示例16: Index

        public ActionResult Index()
        {
            if (Request.IsAuthenticated)
            {
                var claimsIdentity = HttpContext.User.Identity as ClaimsIdentity;
                var claims = claimsIdentity.Claims;

                var accessTokenClaim = claims.FirstOrDefault(x => x.Type == Startup.TwitterAccessTokenClaimType);
                var accessTokenSecretClaim =
                    claims.FirstOrDefault(x => x.Type == Startup.TwitterAccessTokenSecretClaimType);

                if (accessTokenClaim != null && accessTokenSecretClaim != null)
                {
                    var service = new TwitterService(
                        Startup.TwitterConsumerKey,
                        Startup.TwitterConsumerSecret,
                        accessTokenClaim.Value,
                        accessTokenSecretClaim.Value
                        );

                    ViewBag.Tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
                }
            }
            return View();
        }
开发者ID:hossamdarwish,项目名称:AspNetIdentitySocialProfileImage,代码行数:25,代码来源:HomeController.cs


示例17: BritBoxingTwitterInfo

        public BritBoxingTwitterInfo(Cache cache, TwitterService service)
        {
            _cache = cache;
            _service = service;

            UpdateContent();
        }
开发者ID:elmo61,项目名称:BritBoxing,代码行数:7,代码来源:BritBoxingTwitterInfo.cs


示例18: 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


示例19: GetUserToken

        public static void GetUserToken(TwitterService service)
        {
            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);

            Console.WriteLine("Enter this uri into a browser:\n{0}", uri.ToString());

            Console.WriteLine("Enter the pin given by twitter");

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

            if(access == null)
            {
                Console.WriteLine("no tokens returned");
                return;
            }

            Console.WriteLine("Access Token:\n{0}", access.Token);
            Console.WriteLine("Access Secret:\n{0}", access.TokenSecret);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);
        }
开发者ID:mikehadlow,项目名称:socsnap,代码行数:28,代码来源:Main.cs


示例20: SendTextMessage

        private static List<TwitterStatus> SendTextMessage(TwitterService service, MessageEntity message)
        {
            List<TwitterStatus> statuses = new List<TwitterStatus>();

            String hashTag = String.Format("{0}{1}", "#LiveSkypeChat", Environment.NewLine); //TODO: module - defining current top hashtag

            List<string> splittedTwitterMessage = SplitMessage(message.TwitterMessage, hashTag);

            int messgaeIndex = 0;

            foreach (string messagePart in splittedTwitterMessage)
            {
                String twitterMessage = String.Empty;
                messgaeIndex++;

                if (splittedTwitterMessage.Count > 1)
                {
                    String counter = String.Format("{0}/{1}{2}", messgaeIndex, splittedTwitterMessage.Count, Environment.NewLine);
                    twitterMessage = String.Format("{0}{1}{2}: {3}", hashTag, counter, message.TwitterNick, messagePart);
                }
                else
                {
                    twitterMessage = String.Format("{0}{1}: {2}", hashTag, message.TwitterNick, messagePart);
                }

                TwitterStatus status = service.SendTweet(new SendTweetOptions { Status = twitterMessage });
                statuses.Add(status);
            }

            return statuses;
        }
开发者ID:skpSlave,项目名称:skpSlaveBot,代码行数:31,代码来源:TwitterTools.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Twilio.TwilioRestClient类代码示例发布时间:2022-05-26
下一篇:
C# TweetSharp.OAuthRequestToken类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap