static void Main(string[] args) { var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(); Console.Write("**** Time Line *****\n"); Console.Write(oAuthTwitterWrapper.GetMyTimeline() + "\n\n"); Console.Write("**** Search *****\n"); Console.Write(oAuthTwitterWrapper.GetSearch() + "\n\n"); //oAuthTwitterWrapper.TimeLineSettings = new TimeLineSettings { Console.ReadLine(); }
static void Main(string[] args) { var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(); Console.Write("**** Time Line *****\n"); Console.Write(oAuthTwitterWrapper.GetMyTimeline() + "\n\n"); Console.Write("**** Search *****\n"); Console.Write(oAuthTwitterWrapper.GetSearch() + "\n\n"); //oAuthTwitterWrapper.TimeLineSettings = new TimeLineSettings { Console.ReadLine(); }
public static string GetTwitterFeed() { var oAuth = new OAuthConfiguration() { ConsumerToken = "GPdZTjmPRVXP2cgYgjMQ", ConsumerSecret = "LDh41edDBODdRXrvfAjaK5niYGjiaLilaSPDPYOH6LI" }; var twitconfig = new TwitterConfiguration() { ScreenName = "freshupdates" }; var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(oAuth,twitconfig); return oAuthTwitterWrapper.GetMyTimeline(); }
//Add Data source implementations here /// <summary> /// Twitter data source implementation /// </summary> public void GetTwitterResults() { var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(); string rawSearchResults = oAuthTwitterWrapper.GetSearch(); var searchResults = JsonConvert.DeserializeObject <Search>(rawSearchResults); foreach (var result in searchResults.Results) { Posts res = new Posts(); res.Name = result.User.Name; res.PostText = result.Text; string[] hashtags = new string[result.entities.Hashtags.Count]; //Parse hashtags for (int i = 0; i < result.entities.Hashtags.Count; i++) { hashtags[i] = result.entities.Hashtags[i].Text; } //if hashtags are null, place in General category if (hashtags.Length != 0) { res.Category = string.Join(", ", hashtags); } else { res.Category = "General"; } res.Source = "Twitter"; res.GUID = result.id_str; PostResults.Add(res); } }
public static string GetTwitterFeed() { var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(); return(oAuthTwitterWrapper.GetMyTimeline()); }
public JsonResult GetTwitterFeed() { var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(); return Json(oAuthTwitterWrapper.GetMyTimeline(), JsonRequestBehavior.AllowGet); }
public static string GetTwitterFeed() { var oAuthTwitterWrapper = new OAuthTwitterWrapper.OAuthTwitterWrapper(); return oAuthTwitterWrapper.GetMyTimeline(); }
//private string maxIdStr = string.Empty; public void Execute(IJobExecutionContext context) { try { var twit = new OAuthTwitterWrapper.OAuthTwitterWrapper(); Search SearchResponse = new Search() { Results = new List <OAuthTwitterWrapper.JsonTypes.Status>() }; using (SuuEntities SuuContext = new SuuEntities()) { var LastMaxId = SuuContext.OrganizationSettings.Where(s => s.SettingName == "Organization.LastMaxId").FirstOrDefault(); if (string.IsNullOrEmpty(LastMaxId.SettingValue)) { var search = twit.GetSearch(); SearchResponse = JsonConvert.DeserializeObject <Search>(search); LastMaxId.SettingValue = SearchResponse.search_metadata.max_id_str; SuuContext.SaveChanges(); } else if (!string.IsNullOrEmpty(LastMaxId.SettingValue)) { var nextSearch = twit.GetSearch(LastMaxId.SettingValue); var SearchResponse1 = JsonConvert.DeserializeObject <Search>(nextSearch); var SearchResponse1Result = JsonConvert.DeserializeObject <Search>(nextSearch).Results; LastMaxId.SettingValue = SearchResponse1.search_metadata.max_id_str; SuuContext.SaveChanges(); SearchResponse.Results.AddRange(SearchResponse1Result); // var xxxx = new SearchResponse. //var xxx = SearchResponse.Results; } if (SearchResponse.Results.Any()) { var FirstSyncDateTime = SuuContext.OrganizationSettings.Where(s => s.SettingName == "Organization.FirstSyncDateTime").FirstOrDefault(); if (string.IsNullOrEmpty(FirstSyncDateTime.SettingValue)) { FirstSyncDateTime.SettingValue = DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); } var LastSyncDateTime = SuuContext.OrganizationSettings.Where(s => s.SettingName == "Organization.LastSyncDateTime").FirstOrDefault(); LastSyncDateTime.SettingValue = DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); SuuContext.SaveChanges(); for (int a = 0; a < SearchResponse.Results.Count; a++) { var results = SearchResponse.Results; if (results[a].Text.Trim().Substring(0, 2).ToString() != "RT") { //var userLocationLower = results[a].User.Location.ToLower(); //var userLocation = string.Empty; var status = new FrontEnd.Models.Status() { Id = results[a].id, created_at = DateFormatter(results[a].CreatedAt), text = results[a].Text, truncated = results[a].truncated, //entities //metadata source = results[a].source, in_reply_to_status_id = results[a].in_reply_to_status_id, in_reply_to_user_id = results[a].in_reply_to_user_id, in_reply_to_screen_name = results[a].in_reply_to_screen_name, //user //geo = results[a].geo, // coordinates = results[a].coordinates, // place = results[a].place ? results[a].place. : , contributors = results[a].contributors, is_quote_status = results[a].is_quote_status, retweet_count = results[a].retweet_count, favorite_count = results[a].favorite_count, favorited = results[a].favorited, retweeted = results[a].retweeted, lang = results[a].lang, is_count = 0, User = new FrontEnd.Models.User() { Id = results[a].User.Id, name = results[a].User.Name, screen_name = results[a].User.ScreenName, location = results[a].User.Location.ToLower(), description = results[a].User.Description, url = results[a].User.Url, //entities ///->protected followers_count = results[a].User.FollowersCount, friends_count = results[a].User.FriendsCount, listed_count = results[a].User.ListedCount, created_at = DateFormatter(results[a].User.CreatedAt), favourites_count = results[a].User.FavouritesCount, utc_offset = results[a].User.UtcOffset, time_zone = results[a].User.TimeZone, geo_enabled = results[a].User.GeoEnabled, verified = results[a].User.Verified, statuses_count = results[a].User.StatusesCount, lang = results[a].User.Lang, contributors_enabled = results[a].User.ContributorsEnabled, is_translator = results[a].User.IsTranslator, is_translation_enabled = results[a].User.IsTranslationEnabled, profile_background_color = results[a].User.ProfileBackgroundColor, profile_background_image_url = results[a].User.ProfileBackgroundImageUrl, profile_background_image_url_https = results[a].User.ProfileBackgroundImageUrlHttps, // profile_banner_url = results[a].User.profile profile_link_color = results[a].User.ProfileLinkColor, profile_sidebar_border_color = results[a].User.ProfileSidebarBorderColor, profile_sidebar_fill_color = results[a].User.ProfileSidebarFillColor, profile_text_color = results[a].User.ProfileTextColor, profile_use_background_image = results[a].User.ProfileUseBackgroundImage, // has_extended_profile = results[a].User.has default_profile = results[a].User.DefaultProfile, default_profile_image = results[a].User.DefaultProfileImage, following = results[a].User.Following, follow_request_sent = results[a].User.FollowRequestSent, notifications = results[a].User.Notifications, //translator_type = results[a].User.tr profile_image_url = results[a].User.ProfileImageUrl, count = 1, is_ready = 0 } }; var UserIdList = SuuContext.Users.ToList().Select(s => s.Id); var StatusList = SuuContext.Status.ToList().Select(s => s.Id); var HashTagTextList = SuuContext.Hashtags.ToList().Select(s => s.text); if (!StatusList.Contains(status.Id)) { if (UserIdList.Contains(status.User.Id)) { status.user_id = status.User.Id; //status.User = null; //if(string.IsNullOrEmpty(status.User.count) ) var currentUser = SuuContext.Users.ToList().Where(s => s.Id == status.User.Id).FirstOrDefault(); var curentUserCurrentOccrence = currentUser.count; var UserlatestOccurence = curentUserCurrentOccrence = curentUserCurrentOccrence + 1; currentUser.count = UserlatestOccurence; SuuContext.SaveChanges(); status.User = null; } foreach (var x in results[a].entities.Hashtags) { if (!HashTagTextList.Contains(x.Text)) { var EntityHashtag = new EntityHashtag() { status_id = status.Id, Hashtag = new FrontEnd.Models.Hashtag() { text = x.Text, count = 1 }, Status = null }; SuuContext.EntityHashtags.Add(EntityHashtag); } else { //var EntityHashtag = new EntityHashtag() //{ // status_id = status.Id, // Hashtag = new FrontEnd.Models.Hashtag() // { // text = x.Text, // }, // Status = null //}; var currentHashTag = SuuContext.Hashtags.ToList().Where(s => s.text == x.Text).FirstOrDefault(); var curentHashTagCurrentOccrence = currentHashTag.count; var HashTaglatestOccurence = curentHashTagCurrentOccrence = curentHashTagCurrentOccrence + 1; currentHashTag.count = HashTaglatestOccurence; //SuuContext.SaveChanges(); var EntityHashtag = new EntityHashtag() { status_id = status.Id, hashtag_id = currentHashTag.Id }; SuuContext.EntityHashtags.Add(EntityHashtag); // SuuContext.EntityHashtags.Add(EntityHashtag); } } ; SuuContext.Status.Add(status); SuuContext.SaveChanges(); } } } } } Console.WriteLine("finish save to db cycle ........."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }