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


C# TwitterService.AuthenticateWith方法代码示例

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


在下文中一共展示了TwitterService.AuthenticateWith方法的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: Search

        public SearchResultWithRateLimit Search(string queryTerm, int resultType, long sinceId, TwitterApp keys)
        {
            SearchOptions options = new SearchOptions
            {
                Q = System.Web.HttpUtility.UrlEncode(queryTerm),
                Count = 100,
                Lang = "en",
                Resulttype = (TwitterSearchResultType)resultType,
                SinceId = sinceId
            };

            var service = new TwitterService(keys.ConsumerKey, keys.ConsumerKeySecret);
            service.AuthenticateWith(keys.Token, keys.TokenSecret);
            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 = options.SinceId.Value;
            }

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

示例3: Tweeter

        public Tweeter()
        {
            var _consumerKey = "J9iaXHK7R0bpKiRabxQ";
            var _consumerSecret = "Xs6XJggEvXtMVDvaYAvTLnIm13G70ymcdhwQ3J1M";

            // this authentication snippet borrowed from https://github.com/danielcrenna/tweetsharp

            service = new TwitterService(_consumerKey, _consumerSecret);

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

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

            // Step 3 - Exchange the Request Token for an Access Token

            // OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);
            // OAuthAccessToken generated manually through dev.twitter.com so no need for this bit since it's just me tweetin ma shit

            var access = new OAuthAccessToken();
            access.Token = "1196853272-YbSEB0Mnaj6lK3tOKGQ8nwOVLnfhXldwqjlzNmk";
            access.TokenSecret = "4BHhe3iUdlh6o2Re0OmMq3v6e8OwH9vw149MEPR3I";

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);
            // service.SendTweet(new SendTweetOptions { Status = "Hello World" });
        }
开发者ID:joshp123,项目名称:ODESolver,代码行数:29,代码来源:Tweeter.cs

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

示例5: GetAuthenticatedService

 private static TwitterService GetAuthenticatedService()
 {
     var service = new TwitterService(_consumerKey, _consumerSecret);
     service.TraceEnabled = true;
     service.AuthenticateWith(_accessToken, _accessTokenSecret);
     return service;
 }
开发者ID:huynq9,项目名称:MS_TwitterSentimentAnalysis,代码行数:7,代码来源:UserStreaming.cs

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

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

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

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

示例10: Main

        static void Main(string[] args)
        {
            var _consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"].ToString();
            var _consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"].ToString();

            // configure access token
            //var _accessToken = ConfigurationManager.AppSettings["twitterAccess"].ToString();
            //var _accessTokenSecret = ConfigurationManager.AppSettings["twitterAccessSecret"].ToString();

            service = new TwitterService(_consumerKey, _consumerSecret);

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

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

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

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

            //service.AuthenticateWith(_accessToken, _accessTokenSecret);

            //SendATweet();
            //GeoLocationLookup();
            ListFollowers();

            Console.ReadKey();
        }
开发者ID:ericnelson1,项目名称:twitter-app,代码行数:33,代码来源:Program.cs

示例11: IndexModule

        public IndexModule()
        {
            Get["/locations/{user}", true] = async (paramaters, ct) =>
                {
                    var service = new TwitterService(ConfigurationManager.AppSettings["TWITTER_CONSUMER_KEY"], ConfigurationManager.AppSettings["TWITTER_CONSUMER_SECRET"]);
                    service.AuthenticateWith(ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN"], ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN_SECRET"]);
                    string user = paramaters.user.ToString();
                    user.Replace("#", "");

                    var tweets = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions()
                        {
                            ContributorDetails = true,
                            Count = 100,
                            ExcludeReplies = false,
                            IncludeRts = true,
                            ScreenName = user
                        }).ToList();

                    var tweetsWithLocations = tweets.Where(t => t.Location != null).ToList().OrderBy(t => t.CreatedDate);

                    return Response.AsJson(tweetsWithLocations.Select(t => new
                            {
                                LastTweet = t.TextAsHtml,
                                Location = t.Location,
                                Date =
                                      t.CreatedDate.ToShortDateString() + " " +
                                      t.CreatedDate.ToShortTimeString()
                            })).WithHeaders(new []
                            {
                                new { Header = "Access-Control-Allow-Origin", Value="*" }
                            });
                };
        }
开发者ID:rcknight,项目名称:TwitterRadar,代码行数:33,代码来源:IndexModule.cs

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

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

示例14: ApplicationBarIconButton_Click

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            if (img_bool == true && twit_pic == "")
            {
                MessageBox.Show("Image upload in progress. please wait.", "Sorry", MessageBoxButton.OK);
                return;
            }

            if (WatermarkTB.Text == emptystr)
            {
                MessageBox.Show("Please input your mind :)", "Sorry", MessageBoxButton.OK);
                return;
            }

            TwitterService service = new TwitterService("g8F2KdKH40gGp9BXemw13Q", "OyFRFsI05agcJtURtLv8lpYbYRwZAIL5gr5xQNPW0Q");
            service.AuthenticateWith((string)settings["twitter_token"], (string)settings["twitter_tokensecret"]);
            string tweet = WatermarkTB.Text;
            if (img_bool == true)
                tweet += " " + twit_pic;

            service.SendTweet(tweet,
                (tweets, response) =>
                {

                });
            MessageBox.Show("Share successfully.", "Thanks", MessageBoxButton.OK);
            this.NavigationService.GoBack();
        }
开发者ID:vapps,项目名称:HDStream,代码行数:28,代码来源:TwitterWrite.xaml.cs

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


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