static IAuthorizer DoApplicationOnlyAuth() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = Environment.GetEnvironmentVariable(OAuthKeys.TwitterConsumerKey), ConsumerSecret = Environment.GetEnvironmentVariable(OAuthKeys.TwitterConsumerSecret) }, }; return(auth); }
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; }
private static async Task <ApplicationOnlyAuthorizer> SetAuthentication() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "", ConsumerSecret = "" } }; await auth.AuthorizeAsync(); return(auth); }
public async void InitTweetViewModel() { _auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "NVnoGfVhW8R6rwCyD7HvB9TPg", ConsumerSecret = "use3WV06gNmoGq9BsW16Odv3DSgJ2GSnB5K88wTYyPouCg31AU", }, }; await _auth.AuthorizeAsync(); _twitterContext = new TwitterContext(_auth); }
static LinqToTwitterService() { var store = new InMemoryCredentialStore() { ConsumerKey = "8SBo35KV2hEXeOQaW6ZDaw", ConsumerSecret = "fhNwwxui5hd8yeJJb6ZGrsKyxHEPk3d2dk1dLnFo2hM", }; _appAuth = new ApplicationOnlyAuthorizer() { CredentialStore = store }; _appAuth.AuthorizeAsync(); }
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); } }
public async static Task <IAuthorizer> GetAuth() { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore() { ConsumerKey = Secrets.twitterConsumerKey, ConsumerSecret = Secrets.twitterConsumerSecret } }; await auth.AuthorizeAsync(); return(auth); }
static ITwitterAuthorizer DoApplicationOnly() { var auth = new ApplicationOnlyAuthorizer { Credentials = new InMemoryCredentials { ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"], ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"] } }; auth.Authorize(); return(auth); }
private async Task InitializeTwitterContextAsync() { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new SingleUserInMemoryCredentialStore { ConsumerKey = "wamG84e3GpkPjVp08UwsfAZIG", ConsumerSecret = "9lCkCpXJ2FJFINs7329p06alOowqvWNJ2wwFPSTP9MaNu1xGyL" } }; await auth.AuthorizeAsync().ConfigureAwait(false); Context = new TwitterContext(auth); }
static LinqToTwitterService() { MessageBoxService = Container.GetSharedInstance <IMessageBoxService>(); var store = new InMemoryCredentialStore() { ConsumerKey = "8SBo35KV2hEXeOQaW6ZDaw", ConsumerSecret = "fhNwwxui5hd8yeJJb6ZGrsKyxHEPk3d2dk1dLnFo2hM", }; _pinAuth = new ApplicationOnlyAuthorizer() { CredentialStore = store }; _pinAuth.AuthorizeAsync(); }
public static IAuthorizer Authorize() { var keys = GetKeys(); var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = keys.ConsumerKey, ConsumerSecret = keys.ConsumerSecret } }; return(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 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)); }
/// <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 async void Authorize() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = _apiKeys.TwitterConsumerKey, ConsumerSecret = _apiKeys.TwitterConsumerSecretKey }, }; await auth.AuthorizeAsync(); _twitterContext = 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); }
static async Task <IAuthorizer> AuthSampleAsync() { var keys = await GetKeysAsync(); var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = keys.ConsumerKey, ConsumerSecret = keys.ConsumerSecret } }; return(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); }
private async Task <TwitterContext> GetTwitterContext() { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore() { ConsumerKey = ApiKey, ConsumerSecret = ApiKeySecret } }; await auth.AuthorizeAsync(); return(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(); }
public void EncodeCredentials_Returns_Valid_Credentials() { const string ExpectedEncodedCredentials = "eHZ6MWV2RlM0d0VFUFRHRUZQSEJvZzpMOHFxOVBaeVJnNmllS0dFS2hab2xHQzB2SldMdzhpRUo4OERSZHlPZw=="; var auth = new ApplicationOnlyAuthorizer { Credentials = new InMemoryCredentials { ConsumerKey = "xvz1evFS4wEEPTGEFPHBog", ConsumerSecret = "L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg" } }; auth.EncodeCredentials(); Assert.Equal(ExpectedEncodedCredentials, auth.BasicToken); }
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); }
public async Task <IEnumerable <Tweet> > GetTweets() { var tweets = new List <Tweet>(); var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = Clients.Portable.Settings.Current.TwitterApiKey, ConsumerSecret = Clients.Portable.Settings.Current.TwitterApiSecret }, }; await auth.AuthorizeAsync(); var twitterContext = new TwitterContext(auth); var queryResponse = await //twitterContext.Search.W (from tweet in twitterContext.Search where tweet.Type == SearchType.Search && (tweet.Query == "%23CWITC") && tweet.Count == 100 select tweet).SingleOrDefaultAsync(); if (queryResponse == null || queryResponse.Statuses == null) { return(tweets); } tweets = (from tweet in queryResponse.Statuses where tweet.RetweetedStatus.StatusID == 0 && !tweet.PossiblySensitive && !censor.HasCensoredWord(tweet.Text) select new Tweet { TweetedImage = tweet.Entities?.MediaEntities.Count > 0 ? tweet.Entities?.MediaEntities?[0].MediaUrlHttps ?? string.Empty : string.Empty, ScreenName = tweet.User?.ScreenNameResponse ?? string.Empty, Text = tweet.Text, Name = tweet.User.Name, CreatedDate = tweet.CreatedAt, Url = string.Format("https://twitter.com/{0}/status/{1}", tweet.User.ScreenNameResponse, tweet.StatusID), Image = (tweet.RetweetedStatus != null && tweet.RetweetedStatus.User != null ? tweet.RetweetedStatus.User.ProfileImageUrl.Replace("http://", "https://") : tweet.User.ProfileImageUrl.Replace("http://", "https://")) }).Take(15).ToList(); return(tweets); }
/// <summary> /// Returns tweets by SpdDotNet/DotNetRu (if it's retweet then original tweet is returned instead of retweet) /// </summary> /// <returns></returns> public static async Task <List <Tweet> > Get() { try { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "ho0v2B1bimeufLqI1rA8KuLBp", ConsumerSecret = "RAzIHxhkzINUxilhdr98TWTtjgFKXYzkEhaGx8WJiBPh96TXNK" }, }; await auth.AuthorizeAsync(); var twitterContext = new TwitterContext(auth); var spbDotNetTweets = await(from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "spbdotnet" && tweet.TweetMode == TweetMode.Extended select tweet).ToListAsync(); var dotnetruTweets = await(from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "DotNetRu" && tweet.TweetMode == TweetMode.Extended select tweet).ToListAsync(); var unitedTweets = spbDotNetTweets.Union(dotnetruTweets).Where(tweet => !tweet.PossiblySensitive).Select(GetTweet); var tweetsWithoutDuplicates = unitedTweets.GroupBy(tw => tw.StatusID).Select(g => g.First()); var sortedTweets = tweetsWithoutDuplicates.OrderByDescending(x => x.CreatedDate).ToList(); return(sortedTweets); } catch (Exception e) { Logger.Error(e); } return(new List <Tweet>()); }
protected async override void OnCreate(Bundle bundle) { //Generic onCreate for the activity base.OnCreate(bundle); //Gesture management gestureDetector = createGestureDetector(this); //Stops Glass from turning the screen off Window.AddFlags(WindowManagerFlags.KeepScreenOn); //Creates the AudioManager for the tap responses audioManager = (AudioManager)GetSystemService(Context.AudioService); //Load hashtag history using preferences prefs = GetSharedPreferences("tweets", 0); HashSet <String> defaultPrefs = new HashSet <String>(); defaultPrefs.Add("YOlO"); var tempHashtagPrefs = prefs.GetStringSet("hashtags", defaultPrefs); foreach (var x in tempHashtagPrefs) { hashtagPrefs.Add(x); } //Create title card cards = new List <Card>(); AddCard("YOLO (for Glass", "Tap to load cards"); //Set up card scroller scroller = new CardScrollView(this); scroller.Adapter = adapter; //Handles touchpad tap scroller.ItemClick += (system, e) => tweetRefresh(); //Twitter auth and setup var tht = new TwitterHashtags.TwitterHashtags(); auth = await tht.doAuth(); //Activate the view SetContentView(scroller); }
/// <summary> /// Returns tweets by SpdDotNet/DotNetRu (if it's retweet then original tweet is returned instead of retweet) /// </summary> /// <returns> /// Returns a list of tweets. /// </returns> internal static async Task <List <Tweet> > GetAsync(TweetSettings tweetSettings) { try { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = tweetSettings.ConsumerKey, ConsumerSecret = tweetSettings.ConsumerSecret }, }; await auth.AuthorizeAsync(); using var twitterContext = new TwitterContext(auth); var spbDotNetTweets = await(from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "spbdotnet" && tweet.TweetMode == TweetMode.Extended select tweet).ToListAsync(); var dotnetRuTweets = await(from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "DotNetRu" && tweet.TweetMode == TweetMode.Extended select tweet).ToListAsync(); var unitedTweets = spbDotNetTweets.Union(dotnetRuTweets).Where(tweet => !tweet.PossiblySensitive).Select(GetTweet); var tweetsWithoutDuplicates = unitedTweets.GroupBy(tw => tw.StatusID).Select(g => g.First()); var sortedTweets = tweetsWithoutDuplicates.OrderByDescending(x => x.CreatedDate).ToList(); return(sortedTweets); } catch (Exception e) { Logger.LogError(e, "Unhandled error while getting original tweets"); } return(new List <Tweet>()); }
public TwitterTriggerListener(ITriggeredFunctionExecutor executor, ILoggerFactory loggerFactory) { _executor = executor; _loggerFactory = loggerFactory; var authorizer = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = "", ConsumerSecret = "" } }; authorizer.AuthorizeAsync().GetAwaiter().GetResult(); _ctx = new TwitterContext(authorizer); _cache = new Dictionary <ulong, DateTime>(); }
/// <summary> /// Returns tweets by SpdDotNet/DotNetRu (if it's retweet then original tweet is returned instead of retweet) /// </summary> /// <returns> /// Returns a list of tweets. /// </returns> internal static async Task <List <ISocialPost> > GetAsync(TweetSettings tweetSettings, List <string> communities) { try { var auth = new ApplicationOnlyAuthorizer { CredentialStore = new InMemoryCredentialStore { ConsumerKey = tweetSettings.ConsumerKey, ConsumerSecret = tweetSettings.ConsumerSecret }, }; await auth.AuthorizeAsync(); using var twitterContext = new TwitterContext(auth); IEnumerable <Status> unitedTweets = new List <Status>(); foreach (var communityGroup in communities) { var communityGroupTweets = await(from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == communityGroup && tweet.TweetMode == TweetMode.Extended select tweet).ToListAsync(); unitedTweets = communityGroupTweets.Union(unitedTweets).Where(tweet => !tweet.PossiblySensitive); } var tweetsWithoutDuplicates = unitedTweets.Select(GetTweet).GroupBy(tw => tw.StatusId).Select(g => g.First()); var sortedTweets = tweetsWithoutDuplicates.OrderByDescending(x => x.CreatedDate).Cast <ISocialPost>().ToList(); return(sortedTweets); } catch (Exception e) { Logger.LogError(e, "Unhandled error while getting original tweets"); } return(new List <ISocialPost>()); }
public async Task <List <Tweet> > Get() { var auth = new ApplicationOnlyAuthorizer() { CredentialStore = new InMemoryCredentialStore { ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"], ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"], }, }; await auth.AuthorizeAsync(); var twitterContext = new TwitterContext(auth); var tweets = await(from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == "Yurii79584584" && tweet.Count == 100 && tweet.IncludeRetweets == true && tweet.ExcludeReplies == true select new Tweet { StatusID = tweet.StatusID, ScreenName = tweet.User.ScreenNameResponse, Text = tweet.Text, CurrentUserRetweet = tweet.CurrentUserRetweet, CreatedAt = tweet.CreatedAt }).ToListAsync(); foreach (var tweet in tweets) { try { _ourTweetRepository.InsertTweet(tweet); } catch (SqlException ex) { } } return(tweets); }