public async Task <IEnumerable <ITweet> > GetDwxTweets(string searchTerm) { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "LzyD9KdaBGaVOGv7rA6WlMqlC", ConsumerSecret = "nzqWvutFZTaQAWBoMlmvmfWHzQxw7RqWuYtON9YwqBKrH78aPn" } }; await auth.AuthorizeAsync(); using (var ctx = new TwitterContext(auth)) { var searchResults = (from search in ctx.Search where search.Type == SearchType.Search && search.Query == searchTerm select search).SingleOrDefault(); return(searchResults.Statuses.Select(x => new Tweet { Id = x.ID, Text = x.Text, ScreenName = x.ScreenName }).ToList()); } }
public async Task InitTweetViewModel() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "", ConsumerSecret = "", }, }; await auth.AuthorizeAsync(); var ctx = new TwitterContext(auth); Search searchResponse = await (from search in ctx.Search where search.Type == SearchType.Search && search.Query == "\"Twitter\"" select search) .SingleAsync(); Tweets = (from tweet in searchResponse.Statuses select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.Text, ImageUrl = tweet.User.ProfileImageUrl }) .ToList(); }
private async System.Threading.Tasks.Task <TwitterContext> AuthenticateApplicationAsync() { try { var authorizer = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = CONSUMER_KEY, ConsumerSecret = CONSUMER_SECRET } }; //auth = DoApplicationOnlyAuth(); await authorizer.AuthorizeAsync(); var twitterCtx = new TwitterContext(authorizer); return(twitterCtx); } catch (Exception) { //Write to log return(null); } }
public async Task InitTweetsAsync() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "kpq2mqKjL6mKWKlpwkBWKiOQi", ConsumerSecret = "ac9bOcnvSTRU8fEc1Woom4n5c0zlf5iuaoO7gMnsfS4wOK0YDF", }, }; await auth.AuthorizeAsync(); var ctx = new TwitterContext(auth); Search searchResponse = await (from search in ctx.Search where search.Type == SearchType.Search && search.Query == "Twitter" select search) .SingleAsync(); Tweets = (from tweet in searchResponse.Statuses select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.Text, ImageUrl = tweet.User.ProfileImageUrl }) .ToList(); }
private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { WatchedInstrumentsButton.IsEnabled = false; var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = ConfigurationManager.AppSettings["consumerKey"], ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"] }, }; await auth.AuthorizeAsync(); SharedState.Authorizer = auth; var token = _cancellationTokenSource.Token; try { await Task.Factory.StartNew(() => TwitterFeedsService.Instance.LoadCache(token), TaskCreationOptions.LongRunning); Observable.Timer(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30)).Subscribe(time => TwitterFeedsService.Instance.SyncCache()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { WatchedInstrumentsButton.IsEnabled = true; } }
public async Task Poll(CancellationToken stoppingToken, Action <string> tweetReceivedCallback) { stoppingToken.Register(() => _logger.LogDebug($" LinqToTwitterPoller poll task is stopping.")); var auth = new ApplicationOnlyAuthorizer { CredentialStore = _credentials }; await auth.AuthorizeAsync(); var twitterContext = new TwitterContext(auth); _logger.LogDebug($"{nameof(LinqToTwitterPoller)} is starting to poll activity matching {_trackFilter}."); var stream = twitterContext.Streaming.Where(str => str.Type == StreamingType.Filter && str.Track == _trackFilter); await stream.StartAsync(async strm => { tweetReceivedCallback(strm.Content); if (stoppingToken.IsCancellationRequested) { strm.CloseStream(); } }); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); Card card1 = new Card(this); var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "abcdefg", ConsumerSecret = "hijklmn", }, }; await auth.AuthorizeAsync(); var ctx = new TwitterContext(auth); var tweet = await (from twt in ctx.Status where twt.Type == StatusType.Show && twt.ID == 421551271137378304ul select twt) .SingleOrDefaultAsync(); card1.SetText(tweet.Text); card1.SetFootnote( "@" + tweet.User.ScreenNameResponse + " - " + tweet.CreatedAt.ToShortDateString()); View card1View = card1.ToView(); SetContentView(card1View); }
private async Task <List <Status> > LoadData() { var auth = new ApplicationOnlyAuthorizer(); auth.AccessType = AuthAccessType.Read; auth.CredentialStore = new InMemoryCredentialStore() { ConsumerKey = Private.Keys.TWITTER_API_KEY, ConsumerSecret = Private.Keys.TWITTER_API_SECRET }; await auth.AuthorizeAsync(); var context = new TwitterContext(auth); var tweets = new List <Status>(); if (Handle.StartsWith("#")) { var result = await(from tweet in context.Search where tweet.Type == SearchType.Search && tweet.Query == Handle && tweet.ResultType == ResultType.Recent && tweet.Count == 200 select tweet).SingleOrDefaultAsync(); tweets = result.Statuses; } else { tweets = await(from tweet in context.Status where tweet.Type == StatusType.User && tweet.ScreenName == Handle && tweet.Count == 200 select tweet).ToListAsync(); } for (int i = 0; i < tweets.Count; i++) { if (tweets[i].RetweetedStatus != null && tweets[i].RetweetedStatus.StatusID != 0) { tweets[i] = tweets[i].RetweetedStatus; } } return(tweets); }
public async Task InitTweetsAsync() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { // Please use this link to create a new app in Twitter // https://apps.twitter.com/app/new // so you can get ConsumerKey and ConsumerSecret //ConsumerKey = "******", //ConsumerSecret = "*******", ConsumerKey = "kpq2mqKjL6mKWKlpwkBWKiOQi", ConsumerSecret = "ac9bOcnvSTRU8fEc1Woom4n5c0zlf5iuaoO7gMnsfS4wOK0YDF", }, }; await auth.AuthorizeAsync(); var ctx = new TwitterContext(auth); var tweets = await (from tweet in ctx.Status where tweet.Type == StatusType.User && tweet.ScreenName == "HoussemDellai" && tweet.Count == 30 select tweet) .ToListAsync(); Tweets = (from tweet in tweets select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.Text, ImageUrl = tweet.User.ProfileImageUrl, MediaUrl = tweet?.Entities?.MediaEntities?.FirstOrDefault()?.MediaUrl }) .ToList(); //Search searchResponse = await // (from search in ctx.Search // where search.Type == SearchType.Search && // search.Query == "VisualStudio" // select search) // .SingleAsync(); //Tweets = // (from tweet in searchResponse.Statuses // select new Tweet // { // StatusID = tweet.StatusID, // ScreenName = tweet.User.ScreenNameResponse, // Text = tweet.Text, // ImageUrl = tweet.User.ProfileImageUrl // }) // .ToList(); }
private async void ExecuteLoadTweetsCommand() { if (IsBusy) { return; } IsBusy = true; try { Tweets.Clear(); var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "ZTmEODUCChOhLXO4lnUCEbH2I", ConsumerSecret = "Y8z2Wouc5ckFb1a0wjUDT9KAI6DUat5tFNdmIkPLl8T4Nyaa2J", }, }; await auth.AuthorizeAsync(); var twitterContext = new TwitterContext(auth); var searchResponse = await(from search in twitterContext.Search where search.Type == SearchType.Search && search.Count == 100 && search.Query == "\"#dcc14\"" select search) .SingleOrDefaultAsync(); if (searchResponse != null && searchResponse.Statuses != null) { var tweets = (from tweet in searchResponse.Statuses select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.Text, CurrentUserRetweet = tweet.CurrentUserRetweet, CreatedAt = tweet.CreatedAt }).ToList(); foreach (var tweet in tweets) { Tweets.Add(tweet); } } } catch (Exception ex) { var page = new ContentPage(); page.DisplayAlert("Error", "Unable to load twitter.", "OK"); } IsBusy = false; }
public async Task InitTweetsAsync() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { // Please use this link to create a new app in Twitter // https://apps.twitter.com/app/new // so you can get ConsumerKey and ConsumerSecret //ConsumerKey = "******", //ConsumerSecret = "*******", ConsumerKey = "VnglBsHdlbtwPDCX0DMaCOxPe", ConsumerSecret = "MqzOWPP21x8ZMRlNxoanXfsA5i2ta1FR1nOrT7oa6GzamcrOVz", }, }; await auth.AuthorizeAsync(); var ctx = new TwitterContext(auth); var tweets = await (from tweet in ctx.Status where tweet.Type == StatusType.User && tweet.ScreenName == "PokemonGoApp" && tweet.Count == 30 select tweet) .ToListAsync(); Tweets = (from tweet in tweets select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.Text, ImageUrl = tweet.User.ProfileImageUrl, MediaUrl = tweet?.Entities?.MediaEntities?.FirstOrDefault()?.MediaUrl }) .ToList(); //Search searchResponse = await // (from search in ctx.Search // where search.Type == SearchType.Search && // search.Query == "VisualStudio" // select search) // .SingleAsync(); //Tweets = // (from tweet in searchResponse.Statuses // select new Tweet // { // StatusID = tweet.StatusID, // ScreenName = tweet.User.ScreenNameResponse, // Text = tweet.Text, // ImageUrl = tweet.User.ProfileImageUrl // }) // .ToList(); }
public static async Task <List <Tweet> > Get() { try { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "t6tGj3XmaOzDQUnCIgih8gF4F", ConsumerSecret = "EXKnUBVtGvNGQyRDtfAgEnPp2ajfT7NSBQgSai8VRIHO936BDT" }, }; await auth.AuthorizeAsync(); var twitterContext = new TwitterContext(auth); var spbDotNetTweets = await (from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "spbdotnet" select tweet) .ToListAsync(); var dotnetruTweets = await(from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "DotNetRu" select tweet).ToListAsync(); var tweets = (from tweet in spbDotNetTweets.Union(dotnetruTweets) where tweet.RetweetedStatus.StatusID == 0 && !tweet.PossiblySensitive let tweetUser = tweet.User where tweetUser != null select new Tweet { TweetedImage = tweet.Entities?.MediaEntities.Count > 0 ? tweet.Entities?.MediaEntities?[0].MediaUrlHttps ?? string.Empty : string.Empty, ScreenName = tweetUser?.ScreenNameResponse ?? string.Empty, Text = tweet.Text, Name = tweetUser.Name, CreatedDate = tweet.CreatedAt, Url = $"https://twitter.com/{tweetUser.ScreenNameResponse}/status/{tweet.StatusID}", Image = (tweet.RetweetedStatus?.User != null ? tweet.RetweetedStatus.User.ProfileImageUrl.Replace("http://", "https://") : tweetUser.ProfileImageUrl.Replace("http://", "https://")) }).OrderByDescending(x => x.CreatedDate).Take(15).ToList(); return(tweets); } catch { // TODO } return(new List <Tweet>()); }
async Task ExecuteLoadTweetsCommand() { if (IsBusy) { return; } IsBusy = true; Tweets.Clear(); var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "4a8c7X6NqcBT5GY6nWOX9b32P", ConsumerSecret = "QOIvLNS05WfORaQTwvkaxnfH7Rejwi7NgBVUBudtJ0yhiFpCjL", }, }; await auth.AuthorizeAsync(); var twitterContext = new TwitterContext(auth); var queryResponse = await (from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "xamarinhq" && tweet.Count == 20 && tweet.IncludeRetweets == true && tweet.ExcludeReplies == true select tweet).ToListAsync(); var tweets = (from tweet in queryResponse select new Tweet { Name = tweet.User.Name, Time = tweet.CreatedAt, Text = tweet.Text, AvatarUrl = (tweet.RetweetedStatus != null && tweet.RetweetedStatus.User != null ? tweet.RetweetedStatus.User.ProfileImageUrl.Replace("http://", "https://") : tweet.User.ProfileImageUrl.Replace("http://", "https://")) }).ToList(); foreach (var tweet in tweets) { Tweets.Add(tweet); } IsBusy = false; }
static LinqToTwitterService() { var store = new InMemoryCredentialStore() { ConsumerKey = "8SBo35KV2hEXeOQaW6ZDaw", ConsumerSecret = "fhNwwxui5hd8yeJJb6ZGrsKyxHEPk3d2dk1dLnFo2hM", }; _appAuth = new ApplicationOnlyAuthorizer() { CredentialStore = store }; _appAuth.AuthorizeAsync(); }
public async void InitTweetViewModel() { _auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "NVnoGfVhW8R6rwCyD7HvB9TPg", ConsumerSecret = "use3WV06gNmoGq9BsW16Odv3DSgJ2GSnB5K88wTYyPouCg31AU", }, }; await _auth.AuthorizeAsync(); _twitterContext = new TwitterContext(_auth); }
private static async Task <ApplicationOnlyAuthorizer> SetAuthentication() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "", ConsumerSecret = "" } }; await auth.AuthorizeAsync(); return(auth); }
public async Task <List <objTweet> > twitterAsync(string query) { try { lst = new List <objTweet>(); var auth = new ApplicationOnlyAuthorizer { CredentialStore = new SingleUserInMemoryCredentialStore() { ConsumerKey = "LdvwFKY5k5PCKGu5aWgWMs411", ConsumerSecret = "ytXiOge4DoGa1H0cGyis2tBTMgINtxi2ZLQHmnTeBffraJ4tz5", AccessToken = "445048624-rdMueoux3A1NKNY51UVowqXNlUWA0tKv99bC1a1U", AccessTokenSecret = "4XCkCRjIZeOUGLNKYVZvFFfAoPqkzD5IFSI2PvZIowDnz" } }; await auth.AuthorizeAsync(); var twitterCtx = new TwitterContext(auth); Search searchResponse = await (from search in twitterCtx.Search where search.Type == SearchType.Search && search.Query == query select search) .SingleOrDefaultAsync(); if (searchResponse != null && searchResponse.Statuses != null) { searchResponse.Statuses.ForEach(tweet => { lst.Add(new objTweet { text = tweet.Text, likes = tweet.FavoriteCount.ToString() }); }); } return(lst); } catch (Exception ex) { Console.WriteLine(ex); return(null); } }
static LinqToTwitterService() { MessageBoxService = Container.GetSharedInstance <IMessageBoxService>(); var store = new InMemoryCredentialStore() { ConsumerKey = "8SBo35KV2hEXeOQaW6ZDaw", ConsumerSecret = "fhNwwxui5hd8yeJJb6ZGrsKyxHEPk3d2dk1dLnFo2hM", }; _pinAuth = new ApplicationOnlyAuthorizer() { CredentialStore = store }; _pinAuth.AuthorizeAsync(); }
private async Task InitializeTwitterContextAsync() { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new SingleUserInMemoryCredentialStore { ConsumerKey = "wamG84e3GpkPjVp08UwsfAZIG", ConsumerSecret = "9lCkCpXJ2FJFINs7329p06alOowqvWNJ2wwFPSTP9MaNu1xGyL" } }; await auth.AuthorizeAsync().ConfigureAwait(false); Context = new TwitterContext(auth); }
private static async Task <IAuthorizer> AutorizarTwitter() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = Constantes.TwitterApiKey, ConsumerSecret = Constantes.TwitterApiSecret, }, }; await auth.AuthorizeAsync(); return(auth); }
public async static Task <IAuthorizer> GetAuth() { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore() { ConsumerKey = Secrets.twitterConsumerKey, ConsumerSecret = Secrets.twitterConsumerSecret } }; await auth.AuthorizeAsync(); return(auth); }
private async Task <TwitterContext> GetTwitterContext() { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore() { ConsumerKey = ApiKey, ConsumerSecret = ApiKeySecret } }; await auth.AuthorizeAsync(); return(new TwitterContext(auth)); }
async System.Threading.Tasks.Task initTwitter() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "Wc30HCVdXdaNdmzQ3mnqGASzM", ConsumerSecret = "fDcmPOzHEe2CWcpkIfQVyuZglvo52BiTTtSxPlDULmDYwmzkEB" } }; await auth.AuthorizeAsync(); twitterCtx = new TwitterContext(auth); }
async void generatePermissions() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = TwitterAPICredentials.ConsumerApiKey, ConsumerSecret = TwitterAPICredentials.ConsumerApiSecret }, }; await auth.AuthorizeAsync(); ctx = new TwitterContext(auth); GetTweets(); }
/// <inheritdoc /> public async Task <IAuthorizer> GetApplicationOnlyAuthorizer() { var authorizer = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = ConfigurationManager.AppSettings[ApplicationKey.TwitterConsumerKey], ConsumerSecret = ConfigurationManager.AppSettings[ApplicationKey.TwitterConsumerSecret] } }; await authorizer.AuthorizeAsync(); return(authorizer); }
private static async Task <TwitterContext> InitializeTwitterContextAsync() { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new SingleUserInMemoryCredentialStore { ConsumerKey = ConfigurationManager.AppSettings[TwitterConsumerKeyName], ConsumerSecret = ConfigurationManager.AppSettings[TwitterConsumerSecretName], } }; await auth.AuthorizeAsync().ConfigureAwait(false); return(new TwitterContext(auth)); }
private async void Authorize() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = _apiKeys.TwitterConsumerKey, ConsumerSecret = _apiKeys.TwitterConsumerSecretKey }, }; await auth.AuthorizeAsync(); _twitterContext = new TwitterContext(auth); }
private async Task <ApplicationOnlyAuthorizer> SetAuth(string consumerKey, string consumerSecret) { ApplicationOnlyAuthorizer auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore() { ConsumerKey = consumerKey, ConsumerSecret = consumerSecret } }; await auth.AuthorizeAsync(); return(auth); }
private async Task <ApplicationOnlyAuthorizer> SetAuthentication() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore() { ConsumerKey = "6XoTsN2mhm19tsEtfmDIJD9XZ", ConsumerSecret = "n25WEZn538y0csa37w8La2V13KMwcouSO5mYDGF7jJSxordMDw" //OAuthToken = "173770592-AGfE1rXqL4nGMcbNKvzTwT2BamJIeMh4FEyOfZpZ", //OAuthTokenSecret = "FlMnHWIhb99T9dCre0Kw3c6As5IyodXlYIyST6sICc1Oq" } }; await auth.AuthorizeAsync(); return(auth); }
public static List <TwitterResult> SearchAsync(string query) { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret } //CredentialStore = // new SessionStateCredentialStore() // { // ConsumerKey = ConsumerKey, // ConsumerSecret = ConsumerSecret, // } }; var task = auth.AuthorizeAsync(); task.Wait(); var twitterCtx = new TwitterContext(auth); var searchResults = (from search in twitterCtx.Search where search.Type == SearchType.Search && search.Query == query select search.Statuses) .SingleOrDefault(); var twitterResult = new List <TwitterResult>(); if (searchResults != null && searchResults.Count > 0) { foreach (var result in searchResults) { twitterResult.Add(new TwitterResult { Text = result.Text, Url = result.User.Url, ProfileImageUrl = result.User.ProfileImageUrl, ScreenNameResponse = result.User.ScreenNameResponse, CreatedAt = result.CreatedAt }); } } return(twitterResult); }