Пример #1
0
        static ITwitterAuthorizer DoXAuth()
        {
            // validate that credentials are present
            if (ConfigurationManager.AppSettings["twitterConsumerKey"].IsNullOrWhiteSpace() ||
                ConfigurationManager.AppSettings["twitterConsumerSecret"].IsNullOrWhiteSpace())
            {
                Console.WriteLine("You need to set twitterConsumerKey and twitterConsumerSecret in App.config/appSettings. Visit http://dev.twitter.com/apps for more info.\n");
                Console.Write("Press any key to exit...");
                Console.ReadKey();
                return null;
            }

            // configure the OAuth object
            var auth = new XAuthAuthorizer
            {
                Credentials = new XAuthCredentials
                {
                    ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"],
                    UserName = "******",
                    Password = "******"
                }
            };

            // authorize with Twitter
            auth.Authorize();

            return auth;
        }
        private XAuthAuthorizer GetXAuthAuthorizer()
        {
            var auth = new XAuthAuthorizer
                       {
                          Credentials = new XAuthCredentials
                                           {
                                              ConsumerKey = ConfigurationSettings.AppSettings["ConsumerKey"],
                                              ConsumerSecret = ConfigurationSettings.AppSettings["ConsumerSecret"],
                                              AccessToken = ConfigurationSettings.AppSettings["TokenSecret"],
                                              OAuthToken = ConfigurationSettings.AppSettings["Token"]
                                           }
                       };

             auth.Authorize();
             return auth;
        }