public TwitterEntity(TwitterEntity entity) : base(PARTITION_KEY, entity.RowKey) { TwitterId = entity.TwitterId; TwitterIdString = entity.TwitterIdString; TextMessage = entity.TextMessage; Source = entity.Source; FromUser = entity.FromUser; FromUserId = entity.FromUserId; ReplyUserId = entity.ReplyUserId; ReplyScreenName = entity.ReplyScreenName; ResultType = entity.ResultType; LanguageCode = entity.LanguageCode; ProfileImageUrl = entity.ProfileImageUrl; ProfileSecureImageUrl = entity.ProfileSecureImageUrl; Created_At = entity.Created_At; Status = "-1"; TweetType = entity.TweetType; MovieName = entity.MovieName; ArtistName = entity.ArtistName; IsActive = entity.IsActive; }
public static TwitterEntity CreateTwitterEntity(string fromUserId, string textMessage) { var twitterId = Guid.NewGuid().ToString(); var entity = new TwitterEntity(twitterId); entity.TwitterId = twitterId; entity.FromUserId = fromUserId; entity.TextMessage = textMessage; entity.Status = "-1"; return(entity); }
public static bool UpdateTweetById(this IStore store, TwitterEntity tweet) { Debug.Assert(tweet != null); var list = new List<TwitterEntity> { tweet }; var retList = store.UpdateTweetById(list); Debug.Assert(retList.Count == 1); return retList[retList.Keys.FirstOrDefault()]; }
public static TwitterEntity CreateTwitterEntity(string fromUserId, string textMessage) { var twitterId = Guid.NewGuid().ToString(); var entity = new TwitterEntity(twitterId); entity.TwitterId = twitterId; entity.FromUserId = fromUserId; entity.TextMessage = textMessage; entity.Status = "-1"; return entity; }
private List<TwitterEntity> GetLatestTweets(string handle) { List<TwitterEntity> tweets = new List<TwitterEntity>(); #region Twitter Library Setup OAuthTokens oaccesstkn = new OAuthTokens(); string consumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"]; string consumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"]; oaccesstkn.AccessToken = ConfigurationManager.AppSettings["TwitterAccessToken"]; oaccesstkn.AccessTokenSecret = ConfigurationManager.AppSettings["TwitterAccessSecret"]; ; oaccesstkn.ConsumerKey = consumerKey; oaccesstkn.ConsumerSecret = consumerSecret; #endregion try { #region Get Tweets From Twitter WebRequestBuilder webRequest = new WebRequestBuilder(new Uri(string.Format(ConfigurationManager.AppSettings["TwitterUrl"], handle, 500)), HTTPVerb.GET, oaccesstkn); string responseText; using (var response = webRequest.ExecuteRequest()) { using (var reader = new StreamReader(response.GetResponseStream())) { responseText = reader.ReadToEnd(); } } var brr = Encoding.UTF8.GetBytes(responseText); var streamReader = new StreamReader(new MemoryStream(brr)); var serializer = new DataContractJsonSerializer(typeof(SearchResults)); var tweetsResponse = (SearchResults)serializer.ReadObject(streamReader.BaseStream); streamReader.Close(); #endregion foreach (var mmTweetData in tweetsResponse.Results) { var tweetId = mmTweetData.Id.ToString(); try { var myTweet = new TwitterEntity { RowKey = Guid.NewGuid().ToString(), TwitterId = tweetId, TwitterIdString = mmTweetData.Id_Str, TextMessage = mmTweetData.Text, Source = mmTweetData.Source, FromUser = mmTweetData.Source, FromUserId = mmTweetData.ToUserName, ProfileImageUrl = mmTweetData.User.ProfileImageUrl, ProfileSecureImageUrl = mmTweetData.User.ProfileImageUrlHttps, ReplyUserId = mmTweetData.User.FromUserId.ToString(), ReplyScreenName = mmTweetData.User.FromUser, ResultType = mmTweetData.SearchMetaData.ResultType, LanguageCode = mmTweetData.SearchMetaData.IsoLanguageCode, Created_At = ParseTwitterDateTime(mmTweetData.CreatedAt), Status = "-1" }; tweets.Add(myTweet); } catch (Exception) { } } } catch (Exception) { } return tweets; }