public async Task RefreshData() { _auth = _linqToTwitterAuthorizer.GetAuthorizer(Secrets.TwitterAPIKey, Secrets.TwitterAPISecretKey); await _auth.AuthorizeAsync(); //ht--tps://github.com/JoeMayo/LinqToTwitter/wiki/Querying-the-User-Timeline using (var ctx = new TwitterContext(_auth)) { List <Status> tweets = await (from tweet in ctx.Status where tweet.Type == StatusType.User && tweet.ScreenName == UserName && tweet.Count == 200 && tweet.SinceID == 1 /*sinceID*/ && tweet.TweetMode == TweetMode.Extended select tweet) .ToListAsync(); Tweets = (from tweet in tweets select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.FullText, ImageUrl = tweet.User.ProfileImageUrl }) .ToList(); } InitializeChain(); GenerateTweets(GenerateNumber); }
public async Task InitTweetViewModel() { _auth = _linqToTwitterAuthorizer.GetAuthorizer(consumerKey, consumerSecret); await _auth.AuthorizeAsync(); //ht--tps://github.com/JoeMayo/LinqToTwitter/wiki/Querying-the-User-Timeline using (var ctx = new TwitterContext(_auth)) { List <Status> tweets = await (from tweet in ctx.Status where tweet.Type == StatusType.User && tweet.ScreenName == "realDonaldTrump" && tweet.Count == 200 /*MaxTweetsToReturn*/ && tweet.SinceID == 1 /*sinceID*/ && tweet.TweetMode == TweetMode.Extended select tweet) .ToListAsync(); Tweets = (from tweet in tweets select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.FullText, ImageUrl = tweet.User.ProfileImageUrl }) .ToList(); } var chain = new MarkovChain <string>(1); foreach (var t in Tweets) { chain.Add(t.Text.Split(' '), 1); //foreach(var s in t.Text.Split(' ')) //{ // chain.Add(s, 1); //} } Tweets.Add(new Tweet() { Text = "--------------" }); //String testOutput = String.Empty; var rand = new Random(); for (int i = 0; i < 10; i++) { //var word = new string(chain.Chain(rand).ToArray()); //testOutput += " " + word; var sentence = string.Join(" ", chain.Chain(rand)); Tweets.Add(new Tweet() { Text = sentence }); } //Tweets.Add(new Tweet() { Text = testOutput }); }
public MainPageViewModel(ILoginStore loginStoreSvc, ILinqToTwitterAuthorizer authorizeSvc) { _loginStoreService = loginStoreSvc; _userSecrets = loginStoreSvc.GetSecrets(); _authSvc = authorizeSvc; if (_userSecrets != null) { _auth = _authSvc.GetAuthorizer(consumerKey, consumerSecret, _userSecrets.OAuthToken, _userSecrets.OAuthSecret); } }
private async void Oauth_Completed_GetAuthorizer(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs e) { _auth = _authSvc.GetAuthorizer(consumerKey, consumerSecret, e.Account.Properties["oauth_token"], e.Account.Properties["oauth_token_secret"]); await _loginStoreService.SetSecretsAsync( e.Account.Properties["oauth_token"], e.Account.Properties["oauth_token_secret"] ); RefreshTimeline.ChangeCanExecute(); RefreshTimeline.Execute(null); }
public async Task SearchUsers(String partial) { _auth = _linqToTwitterAuthorizer.GetAuthorizer(Secrets.TwitterAPIKey, Secrets.TwitterAPISecretKey); await _auth.AuthorizeAsync(); using (var ctx = new TwitterContext(_auth)) { var foundUsers = await (from user in ctx.User where user.Type == UserType.Search && user.Query == partial select user) .ToListAsync(); if (foundUsers != null) { foundUsers.ForEach(user => Console.WriteLine("User: " + user.ScreenNameResponse)); } } }