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


C# TweetSharp.TwitterService类代码示例

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


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


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