Пример #1
0
 public static void UpdateStatus(string tweet, IOAuthCredentials credentials) {
     var singleUserAuthorizer = new SingleUserAuthorizer {
         Credentials = credentials
     };
     var twitterCtx = new TwitterContext(singleUserAuthorizer);
     twitterCtx.UpdateStatus(tweet);
 }
        public TwitterNotifier()
        {
            //return;
            try
            {
                auth = new LinqToTwitter.SingleUserAuthorizer
                {
                    Credentials = new LinqToTwitter.SingleUserInMemoryCredentials
                    {
                        ConsumerKey = System.Configuration.ConfigurationManager.AppSettings.Get("consumerKey"),
                        ConsumerSecret = System.Configuration.ConfigurationManager.AppSettings.Get("consumerSecret"),
                        //AccessToken = "accessToken",
                        //AccessTokenSecret = "accessTokenSecret"
                        TwitterAccessToken = System.Configuration.ConfigurationManager.AppSettings.Get("accessToken"),
                        TwitterAccessTokenSecret = System.Configuration.ConfigurationManager.AppSettings.Get("accessTokenSecret")
                    }
                };

                auth.Authorize();
            }
            catch (System.Net.WebException wex)
            {
                Console.WriteLine("Authorization or credential error. Response from Twitter: " + wex.Message);
            }
        }
Пример #3
0
        private void MainFunction()
        {
            Tweets.Text = "";
            var auth = new SingleUserAuthorizer
            {
                Credentials = new SingleUserInMemoryCredentials
                {
                    ConsumerKey = "t3aTtDc1ycxZRFGWGe7ODQ",
                    ConsumerSecret = "El1eDr0x9xX1E8gxxV0J4V3vOe9HLQtkYZLhyJ18xpA",
                    TwitterAccessToken = "176353513-dMdE0uB2JQfywVYIH1HCIOxfgnTdjCc9ZNXjOYAG",
                    TwitterAccessTokenSecret = "UTkm8syPwee9eShd7RlRe7lahMygDmK65DhfCsI0oTgdw"
                }
            };

            var twitterCtx = new TwitterContext(auth);
            var tweetResponse =
                (from tweet in twitterCtx.Status
                 where tweet.Type == StatusType.User &&
                       tweet.ScreenName == AccountName.Text &&
                       tweet.IncludeRetweets == true
                 select tweet)
                .ToList();
            var tweets = tweetResponse.OrderByDescending(item => item.CreatedAt).Take(int.Parse(TweetsCount.Text));

            foreach (var tweet in tweets)
            {
                Tweets.Text +="Name : " + tweet.ScreenName + ", Tweet: " + tweet.Text + "\n";
            }
        }
Пример #4
0
        static async void SendTweetWithMultiplePictures()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = "your consumer key",
                    ConsumerSecret = "your consumer secret",
                    AccessToken = "your access token",
                    AccessTokenSecret = "your access token secret"
                }
            };

            var context = new TwitterContext(auth);

            var imageUploadTasks =
                new List<Task<Media>>
                {
                    context.UploadMediaAsync(File.ReadAllBytes(@"c:\path\to\image1.jpg")),
                    context.UploadMediaAsync(File.ReadAllBytes(@"c:\path\to\image2.png")),
                    context.UploadMediaAsync(File.ReadAllBytes(@"c:\path\to\image3.jpg"))
                };
            await Task.WhenAll(imageUploadTasks);
            
            var mediaIds =
                (from tsk in imageUploadTasks
                 select tsk.Result.MediaID)
                .ToList();

            await context.TweetAsync(
                "Photos of Acadia National Park by Kim Seng https://www.flickr.com/photos/captainkimo/ #LinqToTwitter",
                mediaIds
            );
        }
Пример #5
0
        // GET: Twitter
        public ActionResult Index()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
                    AccessToken = ConfigurationManager.AppSettings["accessToken"],
                    AccessTokenSecret = ConfigurationManager.AppSettings["accessTokenSecret"]
                }
            };

            var twitterCtx = new TwitterContext(auth);
            var vm = new TwitterX(); ;

            //vm.Search = twitterCtx.Search
            //    .SingleOrDefault(s => s.Type == SearchType.Search && s.Query == "#windows10");

            vm.Friendship = twitterCtx.Friendship
                .SingleOrDefault(f => f.Type == FriendshipType.FriendsList & f.ScreenName == "aschmach" && f.Count == 200);

            vm.Followers = twitterCtx.Friendship
                .SingleOrDefault(f => f.Type == FriendshipType.FollowersList & f.ScreenName == "aschmach" && f.Count == 200);

            return View(vm);
        }
Пример #6
0
        public async Task<Account> GetTwitterAccount(string userId, string screenName)
        {
            var authTwitter = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = twitterAuthenticationSettings.Value.ConsumerKey,
                    ConsumerSecret = twitterAuthenticationSettings.Value.ConsumerSecret,
                    OAuthToken = twitterAuthenticationSettings.Value.OAuthToken,
                    OAuthTokenSecret = twitterAuthenticationSettings.Value.OAuthSecret,

                    UserID = ulong.Parse(userId),
                    ScreenName = screenName
                }
            };

            await authTwitter.AuthorizeAsync();

            var twitterCtx = new TwitterContext(authTwitter);

            //VERY important you explicitly keep the "== true" part of comparison. ReSharper will prompt you to remove this, and if it does, the query will not work
            var account = await (from acct in twitterCtx.Account
                                 where (acct.Type == AccountType.VerifyCredentials) && (acct.IncludeEmail == true)
                                 select acct).SingleOrDefaultAsync();

            return account;
        }
Пример #7
0
        protected void Application_Start( object sender, EventArgs e )
        {
            ThreadPool.QueueUserWorkItem( _ =>
                                            {
                                                var connectionContext = GlobalHost.ConnectionManager.GetConnectionContext<TweetsConnection>( );
                                                var auth = new SingleUserAuthorizer
                                                               {
                                                                   CredentialStore = new SingleUserInMemoryCredentialStore
                                                                   {
                                                                       ConsumerKey = "",
                                                                       ConsumerSecret = "",
                                                                       AccessToken = "",
                                                                       AccessTokenSecret = ""
                                                                   }
                                                               };

                                                while ( true )
                                                {
                                                    using ( TwitterContext context = new TwitterContext( auth ) )
                                                    {
                                                        var tweets = ( from search in context.Search
                                                                       where search.Type == SearchType.Search && search.Query == "#fnord"
                                                                       select search ).SingleOrDefault( );

                                                        if ( tweets != null && tweets.Statuses != null )
                                                            connectionContext.Connection.Broadcast( tweets.Statuses.Select( t => t.Text ).ToList( ) );
                                                    }
                                                    Thread.Sleep( 5000 );
                                                }
                                            } );
        }
Пример #8
0
        //private int tweetCount;

        //var generator = new MarkovGenerator(markovOrder, false);

        public TweetGenerator(SingleUserAuthorizer auth, string screenname, int count, int order)
        {
            this.auth = auth;
            this.generator = new MarkovGenerator(order, false);
            this.screenname = screenname;
            this.tweetCount = count;
        }
Пример #9
0
        public IActionResult Index(string screenname, string order)
        {
            // TODO handle hashtags separately
            int markovOrder;
            // default order is 2, if the parse failed
            if (!int.TryParse(order, out markovOrder))
                markovOrder = 2;

            // hack to avoid null pointer exception
            if (markovOrder > 5)
                markovOrder = 5;
            int tweetCount = 200;
            var generator = new MarkovGenerator(markovOrder, false);
            
            // how to handle hashtags? just keep a list of them along with a probability for each,
            // i.e. a single-prefix markov chain?
            // would also need a no-hashtag probability
            // no, that won't work, since there wouldn't be an end point, really. at least not one that makes sense.
            
            // what might work is keeping track of individual hashtag probabilities,
            // as well as a probability distribution of number of hashtags. (fun to get some stats on that, see if it's poisson-distributed)

            ViewData["Screenname"] = screenname;

            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = _consumerKey,
                    ConsumerSecret = _consumerSecret,
                    AccessToken = _accessToken,
                    AccessTokenSecret = _accessTokenSecret
                }
            };

            var twitterCtx = new TwitterContext(auth);
            var timeline =
                (twitterCtx.Status.Where(tweet => tweet.Type == StatusType.User &&
                                                  tweet.ScreenName == screenname &&
                                                  tweet.Count == tweetCount))
                    .ToList();

            foreach (var tweet in timeline)
            {
                generator.ReadInput(tweet.Text);
            }

            int outputCount = 20;
            var outputList = new List<string>();
            for (int i = 0; i < outputCount; i++)
            {
                outputList.Add(generator.GenerateOutput());
            }

            //TODO add form
            //TODO use form data
            return View(outputList);
        }
Пример #10
0
        static async Task AsyncMain()
        {
            // Get repositories
            string[] repos = ConfigurationManager.AppSettings["Repositories"]
                .Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => x.Trim())
                .ToArray();

            // Get excluded users
            string[] excludedUsers = ConfigurationManager.AppSettings["ExcludedUsers"]
                .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => x.Trim())
                .ToArray();

            // Authorize to GitHub
            string token = ConfigurationManager.AppSettings["GitHubToken"];
            GitHubClient github = new GitHubClient(new ProductHeaderValue("IssueTweeter"))
            {
                Credentials = new Credentials(token)
            };

            // Get issues for each repo
            DateTimeOffset since = DateTimeOffset.UtcNow.AddHours(-1);
            List<Task<List<KeyValuePair<string, string>>>> issuesTasks = repos.Select(x => GetIssues(github, x, since, excludedUsers)).ToList();
            await Task.WhenAll(issuesTasks);

            // Authorize to Twitter
            SingleUserAuthorizer twitterAuth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"],
                    AccessToken = ConfigurationManager.AppSettings["TwitterAccessToken"],
                    AccessTokenSecret = ConfigurationManager.AppSettings["TwitterAccessTokenSecret"]
                }
            };
            TwitterContext twitterContext = new TwitterContext(twitterAuth);

            // Get recent tweets
            string twitterUser = ConfigurationManager.AppSettings["TwitterUser"];
            List<Status> timeline = await twitterContext.Status
                .Where(x => x.Type == StatusType.User && x.ScreenName == twitterUser && x.Count == 200)
                .ToListAsync();

            // Aggregate and eliminate issues already tweeted
            List<string> tweets = issuesTasks
                .SelectMany(x => x.Result.Where(i => !timeline.Any(t => t.Text.Contains(i.Key))).Select(i => i.Value))
                .ToList();

            // Send tweets
            List<Task<Status>> tweetTasks = tweets.Select(x => twitterContext.TweetAsync(x)).ToList();
            await Task.WhenAll(tweetTasks);
        }
Пример #11
0
 public static SingleUserAuthorizer GetAuthorizer()
 {
     var auth = new SingleUserAuthorizer
     {
         Credentials = new InMemoryCredentials
         {
             ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
             ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"],
             OAuthToken = ConfigurationManager.AppSettings["twitterOAuthToken"],
             AccessToken = ConfigurationManager.AppSettings["twitterAccessToken"]
         }
     };
     return auth;
 }
Пример #12
0
        private async Task <SocialModel> GetTwitterData()
        {
            SocialModel model   = new SocialModel();
            var         account = AccountStore.Create().FindAccountsForService(AccountServiceTwitter).FirstOrDefault();
            var         auth    = new LinqToTwitter.SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey       = "FWinTbxeDRfqL6pd6TyvBWqvY",
                    ConsumerSecret    = "vqHOpCafR8eNNy140xfNRy80W2zyN0A4whM9lcVWj9oSPalDAz",
                    AccessToken       = account.Properties["oauth_token"],
                    AccessTokenSecret = account.Properties["oauth_token_secret"],
                }
            };

            var twitterCtx = new LinqToTwitter.TwitterContext(auth);

            try
            {
                var verifyResponse =
                    await
                        (from acct in twitterCtx.Account
                        where acct.Type == LinqToTwitter.AccountType.VerifyCredentials && (acct.IncludeEmail == true)
                        select acct)
                    .SingleOrDefaultAsync();

                if (verifyResponse != null && verifyResponse.User != null)
                {
                    LinqToTwitter.User user = verifyResponse.User;
                    model.Email     = user.Email;
                    model.Id        = user.UserIDResponse;
                    model.AvatarUrl = user.ProfileImageUrl.Replace("normal", "bigger");
                    model.AuthType  = AuthType.Twitter;
                    if (!String.IsNullOrEmpty(user.Name))
                    {
                        model.Name = user.Name;
                    }
                    else if (!String.IsNullOrEmpty(user.ScreenNameResponse))
                    {
                        model.Name = user.ScreenNameResponse;
                    }
                    return(model);
                }
            }
            catch (LinqToTwitter.TwitterQueryException)
            {
            }

            return(model);
        }
        void CreateContext()
        {
            if (_twitterContext != null)
                _twitterContext.Dispose();

            SingleUserAuthorizer authorizer = new SingleUserAuthorizer()
            {
                Credentials = GetCredentials()
            };
            _twitterContext = new TwitterContext(authorizer)
            {
                Log = Console.Out
            };
        }
Пример #14
0
        public static TwitterContext CreateTwitterContext()
        {
            var xAuthAuthorizer = new SingleUserAuthorizer();
            var inMemoryCredentials = new XAuthCredentials();

            inMemoryCredentials.ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"];
            inMemoryCredentials.ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];
            inMemoryCredentials.OAuthToken = ConfigurationManager.AppSettings["AccessToken"];
            inMemoryCredentials.AccessToken = ConfigurationManager.AppSettings["AccessTokenSecret"];

            xAuthAuthorizer.Credentials = inMemoryCredentials;
            var twitterContext = new TwitterContext(xAuthAuthorizer);
            return twitterContext;
        }
        private TwitterContext GetContext()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = _key,
                    ConsumerSecret = _secret,
                    AccessToken = _token,
                    AccessTokenSecret = _tokenSecret
                }
            };

            return new TwitterContext(auth);
        }
Пример #16
0
 public void Authorise(string consumerKey, string consumerSecret,
     string accessToken, string accessTokenSecret)
 {
     _auth = new SingleUserAuthorizer
     {
         CredentialStore =
             new SingleUserInMemoryCredentialStore
             {
                 ConsumerKey = consumerKey,
                 ConsumerSecret = consumerSecret,
                 AccessToken = accessToken,
                 AccessTokenSecret = accessTokenSecret
             }
     };
 }
Пример #17
0
        private SingleUserAuthorizer Authorize()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new InMemoryCredentialStore
                {
                    ConsumerKey = _consumerKey,
                    ConsumerSecret = _consumerSecret,
                    OAuthToken = _accessToken,
                    OAuthTokenSecret = _accessTokenSecret
                }
            };

            return auth;
        }
 public TwitterContext Build(TwitterCredentials credentials)
 {
     var singleUserAuthorizer = new SingleUserAuthorizer
     {
         CredentialStore = new InMemoryCredentialStore
         {
             ConsumerKey = ConsumerToken.ConsumerKey,
             ConsumerSecret = ConsumerToken.ConsumerSecret,
             OAuthToken = credentials.Tokens.Token,
             OAuthTokenSecret = credentials.Tokens.TokenSecret,
             ScreenName = credentials.ScreenName,
             UserID = (ulong)credentials.UserId
         }
     };
     return new TwitterContext(singleUserAuthorizer);
 }
Пример #19
0
 static void Main(string[] args)
 {
     var auth = new SingleUserAuthorizer {
         Credentials = new SingleUserInMemoryCredentials {
             ConsumerKey = args[0],
             ConsumerSecret = args[1],
             TwitterAccessToken = args[2],
             TwitterAccessTokenSecret = args[3]
         }
     };
     auth.Authorize();
     if (!auth.IsAuthorized)
         throw new AuthenticationException();
     var twitterCtx = new TwitterContext(auth);
     twitterCtx.UpdateStatus(args[4]);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Session["MainUrl"].ToString();
            }
            catch (NullReferenceException)
            {
                Response.Redirect("~/");
                return;
            }

            var ConsumerKey = System.Web.Configuration.WebConfigurationManager.AppSettings["TwitterConsumerKey"];
            var ConsumerSecret = System.Web.Configuration.WebConfigurationManager.AppSettings["TwitterConsumerSecret"];
            var AccessToken = System.Web.Configuration.WebConfigurationManager.AppSettings["TwitterAccessToken"];
            var AccesTokenSecret = System.Web.Configuration.WebConfigurationManager.AppSettings["TwitterAccesTokenSecret"];

            this.authorizer = new SingleUserAuthorizer
                {
                    CredentialStore =
                       new SingleUserInMemoryCredentialStore
                       {
                           ConsumerKey =
                               ConsumerKey,
                           ConsumerSecret =
                              ConsumerSecret,
                           AccessToken =
                              AccessToken,
                           AccessTokenSecret =
                              AccesTokenSecret
                       }
                };

            this.twitterContext = new TwitterContext(authorizer);

            var ths = new ThreadStart(GetTwitter);
            var th = new Thread(ths);
            th.Start();

            th.Join();

            var sb = new System.Text.StringBuilder();
            TwitterSession.RenderControl(new System.Web.UI.HtmlTextWriter(new System.IO.StringWriter(sb)));
            string htmlstring = sb.ToString();

            Session["Twitter"] = htmlstring;
        }
Пример #21
0
        public TweetMiner()
        {
            // Create the context
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = CONSUMER_KEY,
                    ConsumerSecret = CONSUMER_SECRET,
                    AccessToken = TOKEN,
                    AccessTokenSecret = TOKEN_SECRET 
                }
            };

            Twitter = new TwitterContext(auth);

        }
Пример #22
0
        /// <summary>
        /// gets an authorizer object using the details from the config
        /// </summary>
        /// <returns></returns>
        public static ITwitterAuthorizer GetSingleUserAuth()
        {

            // configure the OAuth object
            var auth = new SingleUserAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = ConfigHelper.GetAppSettingString(ConfigKey.TwitterAPIKey),
                    ConsumerSecret = ConfigHelper.GetAppSettingString(ConfigKey.TwitterSecretKey),
                    OAuthToken = ConfigHelper.GetAppSettingString(ConfigKey.TwitterAccessToken),
                    AccessToken = ConfigHelper.GetAppSettingString(ConfigKey.TwitterSecretToken)
                }
            };

            return auth;
        }
Пример #23
0
        public static void tweet(String what)
        {
            XmlNodeList nodes = prepareXML();

            var auth = new SingleUserAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = nodes.Item(0).InnerText,
                    ConsumerSecret = nodes.Item(1).InnerText,
                    OAuthToken = nodes.Item(2).InnerText,
                    AccessToken = nodes.Item(3).InnerText,
                }
            };

            var service = new TwitterContext(auth);
            var tweet = service.UpdateStatus(what.Trim());
        }
Пример #24
0
        static async Task DoStuffAsync()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = "9MUpnlPtNbKYNmJt5jsLaPIQM",
                    ConsumerSecret = "OzBCWTLC4QVn5081LhcRPV6DDbjzUh53nvlUhNmbOy5KoK8aFA",
                    AccessToken = "18138503-SSeuXTfCxyYeBzSu1afhUAsKTX59iJ4UK4zObfmEt",
                    AccessTokenSecret = "9zNHI9DYGVYl7n4dZs8VlsCT6T8W5WHRd4uY7wQAm1lp5",
                }
            };

            await auth.AuthorizeAsync();

            var twitterContext = new TwitterContext(auth);
            await LoadExistingTwitterFriends(twitterContext);
        }
 public TaskController(IDoctrineShipsServices doctrineShipsServices, ISystemLogger logger)
 {
     this.doctrineShipsServices = doctrineShipsServices;
     this.logger = logger;
     this.taskKey = WebConfigurationManager.AppSettings["TaskKey"];
     this.corpApiId = Conversion.StringToInt32(WebConfigurationManager.AppSettings["CorpApiId"]);
     this.corpApiKey = WebConfigurationManager.AppSettings["CorpApiKey"];
     this.twitterAuth = new SingleUserAuthorizer
     {
         CredentialStore = new SingleUserInMemoryCredentialStore
         {
             ConsumerKey = WebConfigurationManager.AppSettings["TwitterConsumerKey"],
             ConsumerSecret = WebConfigurationManager.AppSettings["TwitterConsumerSecret"],
             AccessToken = WebConfigurationManager.AppSettings["TwitterAccessToken"],
             AccessTokenSecret = WebConfigurationManager.AppSettings["TwitterAccessTokenSecret"]
         }
     };
     this.twitterContext = new TwitterContext(this.twitterAuth);
 }
Пример #26
0
        static void Main(string[] args)
        {
            Task.Run(async () =>
            {

                AppSettingsReader cfgReader = new AppSettingsReader();

                string _UseProxy = cfgReader.GetValue("UseProxy", typeof(string)).ToString();

                var auth = new SingleUserAuthorizer
                {
                    CredentialStore = new SingleUserInMemoryCredentialStore
                    {
                        ConsumerKey = cfgReader.GetValue("ConsumerKey", typeof(string)).ToString(),
                        ConsumerSecret = cfgReader.GetValue("ConsumerSecret", typeof(string)).ToString(),
                        AccessToken = cfgReader.GetValue("AccessToken", typeof(string)).ToString(),
                        AccessTokenSecret = cfgReader.GetValue("AccessSecret", typeof(string)).ToString()
                    }
                };

                if (_UseProxy.Equals("1"))
                {
                    auth.Proxy = new WebProxy(cfgReader.GetValue("ProxyAddress", typeof(string)).ToString());
                    auth.Proxy.Credentials = new NetworkCredential(
                        cfgReader.GetValue("ProxyUser", typeof(string)).ToString(),
                        cfgReader.GetValue("ProxyPass", typeof(string)).ToString());
                }

                var twitterContext = new TwitterContext(auth);

                string _teste = "Tweet sent via LinqToTwitter";

                var tweet = await twitterContext.TweetAsync(_teste);

                if (tweet != null)
                {
                    Console.WriteLine("Status: {0}", tweet.StatusID.ToString());
                }

            }).Wait();

            Console.ReadLine();
        }
Пример #27
0
        public TwitterService(IConfigurationRoot configuration)
        {
            this.configuration = configuration;

            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = configuration["Twitter:ConsumerKey"],
                    ConsumerSecret = configuration["Twitter:ConsumerSecret"],
                    AccessToken = configuration["Twitter:AccessToken"],
                    AccessTokenSecret = configuration["Twitter:AccessTokenSecret"]
                }
            };

            auth.AuthorizeAsync().Wait();

            twitterContext = new TwitterContext(auth);
        }
Пример #28
0
        private static TwitterContext ConnectToTwitter()
        {
            Console.WriteLine("Connecting to twitter");
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = ConfigurationManager.AppSettings["apiKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["apiSecret"],
                    AccessToken = ConfigurationManager.AppSettings["accessToken"],
                    AccessTokenSecret = ConfigurationManager.AppSettings["accessTokenSecret"]
                }
            };

            var context = new TwitterContext(auth);

            Console.WriteLine("Connected to twitter");
            return context;
        }
Пример #29
0
 public StatsViewModel(string userName)
 {
     UserName = userName;
     AllTweets = new List<Status>();
     Auth = new SingleUserAuthorizer()
     {
         Credentials = new SingleUserInMemoryCredentials()
         {
             ConsumerKey =
                 ConfigurationManager.AppSettings["TWITTER_CONSUMER_KEY"],
             ConsumerSecret =
                 ConfigurationManager.AppSettings["TWITTER_CONSUMER_SECRET"],
             TwitterAccessToken =
                 ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN"],
             TwitterAccessTokenSecret =
                 ConfigurationManager.AppSettings["TWITTER_ACCESS_TOKEN_SECRET"]
         }
     };
     Update();
 }
Пример #30
0
        /// <summary>
        /// Logon
        /// </summary>
        /// <returns></returns>
        private Twitter.ITwitterAuthorizer PerformAuthorization(string accessToken, string accessSecret, string authenticationKey, string autenthicationSecret)
        {
            Properties.Settings settings = new Properties.Settings();

            var auth = new Twitter.SingleUserAuthorizer
            {
                Credentials = new Twitter.InMemoryCredentials
                {
                    OAuthToken     = accessToken,
                    AccessToken    = accessSecret,
                    ConsumerKey    = authenticationKey,
                    ConsumerSecret = autenthicationSecret,
                },
                UseCompression = true,
            };

            auth.Authorize();

            return(auth);
        }
        private ITwitterAuthorizer GetInformasiKredensial()
        {
            string _consumer_key = ConfigurationManager.AppSettings["twitterConsumerKey"];
            string _secret_key = ConfigurationManager.AppSettings["twitterConsumerSecret"];
            string _access_token = ConfigurationManager.AppSettings["twitterOAuthToken"];
            string _access_token_secret = ConfigurationManager.AppSettings["twitterAccessToken"];

            var auth = new SingleUserAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = _consumer_key,
                    ConsumerSecret = _secret_key,
                    OAuthToken = _access_token,
                    AccessToken = _access_token_secret
                }
            };

            return auth;
        }
        public static TwitterContext GetContext()
        {
            const string _key = "enterKey";
            const string _secret = "enterSecret";
            const string _token = "enterToken";
            const string _tokenSecret = "enterTokenSecret";

            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = _key,
                    ConsumerSecret = _secret,
                    AccessToken = _token,
                    AccessTokenSecret = _tokenSecret
                }
            };

            return new TwitterContext(auth);
        }