public void getTwitterData(object UserId) { try { Guid userId = (Guid)UserId; oAuthTwitter OAuth = new oAuthTwitter(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]); TwitterAccountRepository objTwtRepo = new TwitterAccountRepository(); ArrayList arrTwtAcc = objTwtRepo.getAllTwitterAccountsOfUser(userId); foreach (TwitterAccount itemTwt in arrTwtAcc) { OAuth.AccessToken = itemTwt.OAuthToken; OAuth.AccessTokenSecret = itemTwt.OAuthSecret; getUserProile(OAuth, itemTwt.TwitterUserId, userId); getUserTweets(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId); getUserFeed(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
/// <summary> /// This Method Get All Followers Details of User /// </summary> /// <param name="oAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="ScreenName">User Screen Name</param> /// <returns></returns> public XmlDocument FollowersStatus(oAuthTwitter oAuth, string ScreenName, string cursor) { string RequestUrl = Globals.FollowerStatusUrl + ScreenName + ".xml?cursor=" + cursor; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, string.Empty); xmlResult.Load(new StringReader(response)); return xmlResult; }
/// <summary> /// This Method Will Get All Friends Id of User /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="ScreenName">ScreenName Of Whom You Want To Get FriendsId</param> /// <returns>All Friends Id</returns> public XmlDocument FriendsId(oAuthTwitter OAuth, string ScreenName, SortedDictionary<string, string> strdic) { string RequestUrl = Globals.FriendsIdUrl + ScreenName; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET,RequestUrl,strdic); xmlResult.Load(new StringReader(response)); return xmlResult; }
public override void PostScheduleMessage(dynamic data) { try { oAuthTwitter OAuthTwt = new oAuthTwitter(); TwitterAccountRepository fbaccrepo = new TwitterAccountRepository(); TwitterAccount twtaccount = fbaccrepo.getUserInformation(data.UserId, data.ProfileId); OAuthTwt.CallBackUrl = System.Configuration.ConfigurationSettings.AppSettings["callbackurl"]; OAuthTwt.ConsumerKey = System.Configuration.ConfigurationSettings.AppSettings["consumerKey"]; OAuthTwt.ConsumerKeySecret = System.Configuration.ConfigurationSettings.AppSettings["consumerSecret"]; OAuthTwt.AccessToken = twtaccount.OAuthToken; OAuthTwt.AccessTokenSecret = twtaccount.OAuthSecret; OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName; OAuthTwt.TwitterUserId = twtaccount.TwitterUserId; #region For Testing // For Testing //OAuthTwt.ConsumerKey = "udiFfPxtCcwXWl05wTgx6w"; //OAuthTwt.ConsumerKeySecret = "jutnq6N32Rb7cgbDSgfsrUVgRQKMbUB34yuvAfCqTI"; //OAuthTwt.AccessToken = "1904022338-Ao9chvPouIU8ejE1HMG4yJsP3hOgEoXJoNRYUF7"; //OAuthTwt.AccessTokenSecret = "Wj93a8csVFfaFS1MnHjbmbPD3V6DJbhEIf4lgSAefORZ5"; //OAuthTwt.TwitterScreenName = ""; //OAuthTwt.TwitterUserId = ""; #endregion TwitterUser twtuser = new TwitterUser(); if (string.IsNullOrEmpty(data.ShareMessage)) { data.ShareMessage = "There is no data in Share Message !"; } JArray post = twtuser.Post_Status_Update(OAuthTwt, data.ShareMessage); Console.WriteLine("Message post on twitter for Id :" + twtaccount.TwitterUserId + " and Message: " + data.ShareMessage); ScheduledMessageRepository schrepo = new ScheduledMessageRepository(); schrepo.updateMessage(data.Id); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Log log = new Log(); log.CreatedDate = DateTime.Now; log.Exception = ex.Message; log.Id = Guid.NewGuid(); log.ModuleName = "TwitterScheduler"; log.ProfileId = data.ProfileId; log.Status = false; LogRepository logRepo = new LogRepository(); logRepo.AddLog(log); } }
//#region OAuth ///// <summary> ///// This Method Will Check That User is Authenticated Or Not Using OAUTH ///// </summary> ///// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> ///// <returns>Return Xml Text With User Details</returns> //public XmlDocument Verify_Credentials(oAuthTwitter OAuth) //{ // string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, Globals.VerifyCredentialsUrl, String.Empty); // xmlResult.Load(new StringReader(response)); // return xmlResult; //} /// <summary> /// This method Will Check Rate Limit Of Account Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Return Xml Text With User Details</returns> public XmlDocument Rate_Limit_Status(oAuthTwitter OAuth, SortedDictionary<string, string> strdic) { string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, Globals.RateLimitStatusUrl, strdic); xmlResult.Load(new StringReader(response)); return xmlResult; }
public JObject SearchMethodForTwtUser(oAuthTwitter OAuth, string SearchKey, string pageindex) { TwitterWebRequest twtWebReq = new TwitterWebRequest(); string RequestUrl = Globals.SearchTwtUserUrl + SearchKey + "&page=" + pageindex; JObject response = objTwitterWebRequest.PerformWebRequest(RequestUrl, "GET"); return response; }
/// <summary> /// This Method Will Get All Followers Id of User /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <param name="ScreenName">ScreenName Of Whom You Want To Get Followers Id</param> /// <returns>All Followers Id</returns> public XmlDocument FollowersId(oAuthTwitter OAuth, string ScreenName) { string RequestUrl = Globals.FollowersIdUrl + ScreenName; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET,RequestUrl,string.Empty); xmlResult.Load(new StringReader(response)); return xmlResult; }
public static bool FollowAccount(string AccessToken,string AccessTokenSecret ,string Screen_name, string user_id) { bool IsFollowed = false; oAuthTwitter oauth = new oAuthTwitter(); oauth.AccessToken = AccessToken; oauth.AccessTokenSecret = AccessTokenSecret; oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"]; string RequestUrl = "https://api.twitter.com/1.1/friendships/create.json"; SortedDictionary<string, string> strdic = new SortedDictionary<string, string>(); if (!string.IsNullOrEmpty(Screen_name)) { strdic.Add("screen_name", Screen_name); } else if (!string.IsNullOrEmpty(user_id)) { strdic.Add("user_id", user_id); } else { return false; } strdic.Add("follow", "true"); string response = oauth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); if (!string.IsNullOrEmpty(response)) { IsFollowed = true; } return IsFollowed; }
public override void PostScheduleMessage(dynamic data) { try { oAuthTwitter OAuthTwt = new oAuthTwitter(); TwitterAccountRepository fbaccrepo = new TwitterAccountRepository(); TwitterAccount twtaccount = fbaccrepo.getUserInformation(data.UserId, data.ProfileId); OAuthTwt.CallBackUrl = System.Configuration.ConfigurationSettings.AppSettings["callbackurl"]; OAuthTwt.ConsumerKey = System.Configuration.ConfigurationSettings.AppSettings["consumerKey"]; OAuthTwt.ConsumerKeySecret= System.Configuration.ConfigurationSettings.AppSettings["consumerSecret"]; OAuthTwt.AccessToken = twtaccount.OAuthToken; OAuthTwt.AccessTokenSecret= twtaccount.OAuthSecret; OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName; TwitterUser twtuser = new TwitterUser(); JArray post = twtuser.Post_Status_Update(OAuthTwt, data.ShareMessage); Console.WriteLine("Message post on twitter for Id :" + twtaccount.TwitterUserId + " and Message: " + data.ShareMessage); ScheduledMessageRepository schrepo = new ScheduledMessageRepository(); schrepo.updateMessage(data.Id); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
/// <summary> /// This Method Will Get All Trends Of Twitter Using OAUTH /// </summary> /// <param name="User">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Json Text Of Trends</returns> public XmlDocument SearchMethod(oAuthTwitter OAuth, string SearchKey, string pageindex) { TwitterWebRequest twtWebReq = new TwitterWebRequest(); string RequestUrl = Globals.SearchUrl + SearchKey + "&page=" + pageindex; string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl,string.Empty); xmlResult.Load(new StringReader(response)); return xmlResult; }
/// <summary> /// This Method Will Check That User is Authenticated Or Not Using OAUTH /// </summary> /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Return Xml Text With User Details</returns> public JArray Verify_Credentials(oAuthTwitter OAuth) { SortedDictionary<string, string> strdic = new SortedDictionary<string, string>(); string response = OAuth.oAuthWebRequest(oAuthTwitter.Method.GET, Globals.VerifyCredentialsUrl, strdic); //xmlResult.Load(new StringReader(response)); if (!response.StartsWith("[")) response = "[" + response + "]"; return JArray.Parse(response); }
/// <summary> /// Destroys the status specified by the required ID parameter. The authenticating user must be the author of the specified status. Returns the destroyed status if successful. /// </summary> /// <param name="oAuth"></param> /// <param name="UserId"></param> /// <returns></returns> public JArray Post_Statuses_DestroyById(oAuthTwitter oAuth, string UserId) { SortedDictionary<string, string> strdic = new SortedDictionary<string, string>(); string RequestUrl = Globals.StatusDestroyByIdUrl + UserId + ".json"; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic); if (!response.StartsWith("[")) response = "[" + response + "]"; return JArray.Parse(response); }
public void AuthenticateTwitter(object sender, EventArgs e) { oAuthTwitter OAuth = new oAuthTwitter(); if (Request["oauth_token"] == null) { OAuth.AccessToken = string.Empty; OAuth.AccessTokenSecret = string.Empty; OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString(); Response.Redirect(OAuth.AuthorizationLinkGet()); } }
/// <summary> /// This Method Will Check That User Is Authenticatde Or Not /// </summary> /// <param name="oAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param> /// <returns>Return True If User Is Authenticated</returns> public bool Verify_Credentials(oAuthTwitter oAuth) { Twitter.Core.AccountMethods.Account account = new Twitter.Core.AccountMethods.Account(); JArray obj = account.Verify_Credentials(oAuth); // XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("user"); foreach (var item in obj) { //XmlElement idElement = (XmlElement)xmlNode; //twitterUser.UserID = idElement.GetElementsByTagName("id")[0].InnerText; return true; } return false; }
public bool CheckTwitterToken(oAuthTwitter objoAuthTwitter, string txtvalue) { bool CheckTwitterToken = false; //oAuthTwitter oAuthTwt = new oAuthTwitter(); Users twtUser = new Users(); try { JArray twtuserjson = twtUser.Get_Users_Search(objoAuthTwitter, txtvalue, "5"); CheckTwitterToken = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } return CheckTwitterToken; }
public void AuthenticateTwitter(object sender, EventArgs e) { TwitterHelper twthelper = new TwitterHelper(); string twtredirecturl = twthelper.TwitterRedirect(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]); Response.Redirect(twtredirecturl); oAuthTwitter OAuth = new oAuthTwitter(); if (Request["oauth_token"] == null) { OAuth.AccessToken = string.Empty; OAuth.AccessTokenSecret = string.Empty; OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString(); this.TwitterOAuth.HRef = OAuth.AuthorizationLinkGet(); Response.Redirect(OAuth.AuthorizationLinkGet()); } }
public int FollowersCount(oAuthTwitter oAuth, string screenname, SortedDictionary<string, string> strdic) { string RequestUrl = "https://api.twitter.com/1/users/lookup.xml?screen_name=" + screenname; string response = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, RequestUrl, strdic); xmlResult.Load(new StringReader(response)); TwitterUser twtUser = new TwitterUser(); XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("user"); int count = 0; foreach (XmlNode xn in xmlNodeList) { XmlElement idElement = (XmlElement)xn; count = Convert.ToInt32(idElement.GetElementsByTagName("followers_count")[0].InnerText); } return count; }
public void GetTwitterFeedsAPI(string UserId, string TwitterId) { try { Guid userId = Guid.Parse(UserId); UserRepository userrepo = new UserRepository(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); TwitterAccount twtAcc = twtAccRepo.getUserInformation(userId, TwitterId); oAuthTwitter oAuth = new oAuthTwitter(); oAuth.AccessToken = twtAcc.OAuthToken; oAuth.AccessTokenSecret = twtAcc.OAuthSecret; oAuth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; oAuth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"]; oAuth.TwitterUserId = twtAcc.TwitterUserId; oAuth.TwitterScreenName = twtAcc.TwitterScreenName; TwitterHelper twtHelper = new TwitterHelper(); twtHelper.getUserFeed(oAuth, twtAcc, userId); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public string getresults(string keyword) { User user = (User)Session["LoggedUser"]; int i = 0; string searchRes = string.Empty; if (!string.IsNullOrEmpty(keyword)) { DiscoverySearch dissearch = new DiscoverySearch(); DiscoverySearchRepository dissearchrepo = new DiscoverySearchRepository(); List<DiscoverySearch> discoveryList = dissearchrepo.getResultsFromKeyword(keyword); if (discoveryList.Count == 0) { #region Twitter try { oAuthTwitter oauth = new oAuthTwitter(); oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(); oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"].ToString(); oauth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); ArrayList alst = twtAccRepo.getAllTwitterAccounts(); foreach (TwitterAccount item in alst) { oauth.AccessToken = item.OAuthToken; oauth.AccessTokenSecret = item.OAuthSecret; oauth.TwitterUserId = item.TwitterUserId; oauth.TwitterScreenName = item.TwitterScreenName; break; } Search search = new Search(); JArray twitterSearchResult = search.Get_Search_Tweets(oauth, keyword); foreach (var item in twitterSearchResult) { var results = item["statuses"]; foreach (var chile in results) { try { dissearch.CreatedTime = SocioBoard.Helper.Extensions.ParseTwitterTime(chile["created_at"].ToString().TrimStart('"').TrimEnd('"')); ; dissearch.EntryDate = DateTime.Now; dissearch.FromId = chile["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); dissearch.FromName = chile["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); dissearch.ProfileImageUrl = chile["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); dissearch.SearchKeyword = txtSearchText.Text; dissearch.Network = "twitter"; dissearch.Message = chile["text"].ToString().TrimStart('"').TrimEnd('"'); dissearch.MessageId = chile["id_str"].ToString().TrimStart('"').TrimEnd('"'); dissearch.Id = Guid.NewGuid(); dissearch.UserId = user.Id; if (!dissearchrepo.isKeywordPresent(dissearch.SearchKeyword, dissearch.MessageId)) { dissearchrepo.addNewSearchResult(dissearch); } searchRes += this.BindData(dissearch, i); i++; } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } #endregion #region Facebook try { #region FacebookSearch int j = 0; string accesstoken = string.Empty; FacebookAccountRepository fbAccRepo = new FacebookAccountRepository(); ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts(); foreach (FacebookAccount item in asltFbAccount) { accesstoken = item.AccessToken; break; } string facebookSearchUrl = "https://graph.facebook.com/search?q=" + txtSearchText.Text + " &type=post&access_token="+accesstoken; var facerequest = (HttpWebRequest)WebRequest.Create(facebookSearchUrl); facerequest.Method = "GET"; string outputface = string.Empty; using (var response = facerequest.GetResponse()) { using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252))) { outputface = stream.ReadToEnd(); } } if (!outputface.StartsWith("[")) outputface = "[" + outputface + "]"; JArray facebookSearchResult = JArray.Parse(outputface); foreach (var item in facebookSearchResult) { var data = item["data"]; foreach (var chile in data) { try { dissearch.CreatedTime = DateTime.Parse(chile["created_time"].ToString()); dissearch.EntryDate = DateTime.Now; dissearch.FromId = chile["from"]["id"].ToString(); dissearch.FromName = chile["from"]["name"].ToString(); dissearch.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small"; dissearch.SearchKeyword = txtSearchText.Text; dissearch.Network = "facebook"; dissearch.Message = chile["message"].ToString(); dissearch.MessageId = chile["id"].ToString(); dissearch.Id = Guid.NewGuid(); dissearch.UserId = user.Id; if (!dissearchrepo.isKeywordPresent(dissearch.SearchKeyword, dissearch.MessageId)) { dissearchrepo.addNewSearchResult(dissearch); } searchRes += this.BindData(dissearch, i); } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } #endregion #endregion } else { foreach (DiscoverySearch item in discoveryList) { searchRes += this.BindData(item, i); i++; } } } return searchRes; }
public string AddTwitterAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string requestToken, string requestSecret, string requestVerifier) { try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; Users userinfo = new Users(); oAuthTwitter OAuth = new oAuthTwitter(client_id, client_secret, redirect_uri); OAuth.AccessToken = requestToken; OAuth.AccessTokenSecret = requestVerifier; OAuth.AccessTokenGet(requestToken, requestVerifier); JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName); if (profile != null) { logger.Error("Twitter.asmx >> AddTwitterAccount >> Twitter profile : " + profile); } else { logger.Error("Twitter.asmx >> AddTwitterAccount >> NULL Twitter profile : " + profile); } objTwitterAccount = new Domain.Socioboard.Domain.TwitterAccount(); TwitterUser twtuser; foreach (var item in profile) { #region Add Twitter Account try { objTwitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString()); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objTwitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objTwitterAccount.Id = Guid.NewGuid(); objTwitterAccount.IsActive = true; objTwitterAccount.OAuthSecret = OAuth.AccessTokenSecret; objTwitterAccount.OAuthToken = OAuth.AccessToken; try { objTwitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterAccount.ProfileUrl = string.Empty; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { objTwitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } Console.WriteLine(er.StackTrace); } try { objTwitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } objTwitterAccount.UserId = Guid.Parse(UserId); #endregion if (!objTwitterAccountRepository.checkTwitterUserExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId))) { objTwitterAccountRepository.addTwitterkUser(objTwitterAccount); #region Add TeamMemberProfile Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "twitter"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objTwitterAccount.TwitterUserId; objTeamMemberProfile.ProfileName = objTwitterAccount.TwitterScreenName; objTeamMemberProfile.ProfilePicUrl = objTwitterAccount.ProfileImageUrl; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "twitter"; objSocialProfile.ProfileId = objTwitterAccount.TwitterUserId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion #region Add Twitter Stats if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } objTwitterStats = new Domain.Socioboard.Domain.TwitterStats(); Random rNum = new Random(); objTwitterStats.Id = Guid.NewGuid(); objTwitterStats.TwitterId = objTwitterAccount.TwitterUserId; objTwitterStats.UserId = Guid.Parse(UserId); objTwitterStats.FollowingCount = objTwitterAccount.FollowingCount; objTwitterStats.FollowerCount = objTwitterAccount.FollowersCount; objTwitterStats.Age1820 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age2124 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age2534 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age3544 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age4554 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age5564 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age65 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.EntryDate = DateTime.Now; if (!objTwtstats.checkTwitterStatsExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId))) { objTwtstats.addTwitterStats(objTwitterStats); } #endregion #region AddTwitterFollowerCount Domain.Socioboard.Domain.TwitterAccountFollowers objTwitterAccountFollowers = new Domain.Socioboard.Domain.TwitterAccountFollowers(); TwitterAccountFollowersRepository objTwitterAccountFollowersRepository = new TwitterAccountFollowersRepository(); objTwitterAccountFollowers.Id = Guid.NewGuid(); objTwitterAccountFollowers.UserId = Guid.Parse(UserId); objTwitterAccountFollowers.EntryDate = DateTime.Now; objTwitterAccountFollowers.FollowingsCount = Convert.ToInt32(item["friends_count"].ToString()); objTwitterAccountFollowers.FollowersCount = Convert.ToInt32(item["followers_count"].ToString()); try { objTwitterAccountFollowers.ProfileId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { objTwitterAccountFollowers.ProfileId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } Console.WriteLine(er.StackTrace); } objTwitterAccountFollowersRepository.addTwitterAccountFollower(objTwitterAccountFollowers); #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } } getTwitterMessages(UserId, OAuth); getUserRetweets(UserId, OAuth); //edited by avinash[24-03-15] getTwitterEngagement(UserId, OAuth); getUserTweets(UserId, OAuth); getTwitterFeeds(UserId, OAuth); getTwitterDirectMessageSent(UserId, OAuth); getTwittwrDirectMessageRecieved(OAuth,UserId); getUserMentions(OAuth, objTwitterAccount.TwitterUserId, Guid.Parse(UserId)); getUserFollowers(OAuth, objTwitterAccount.TwitterScreenName, objTwitterAccount.TwitterUserId, Guid.Parse(UserId)); getUserRetweet(OAuth, objTwitterAccount.TwitterUserId, Guid.Parse(UserId)); //return ret; return new JavaScriptSerializer().Serialize(objTwitterAccount); } catch (Exception ex) { logger.Error(ex.StackTrace); return ""; } }
public String getTwitterData(string UserId, string twitterid) { string ret = string.Empty; try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; Guid userId = Guid.Parse(UserId); oAuthTwitter OAuth = new oAuthTwitter(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]); TwitterAccountRepository objTwtRepo = new TwitterAccountRepository(); List<Domain.Socioboard.Domain.TwitterAccount> lstTwitterAccount = objTwtRepo.getAllTwitterAccountsOfUser(userId); foreach (Domain.Socioboard.Domain.TwitterAccount itemTwt in lstTwitterAccount) { string profileId = string.Empty; OAuth.AccessToken = itemTwt.OAuthToken; OAuth.AccessTokenSecret = itemTwt.OAuthSecret; getUserProile(OAuth, itemTwt.TwitterUserId, userId); //getUserTweets(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId); getUserTweets(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId, itemTwt); gettwitterengagement(OAuth, userId, itemTwt); getUserFeed(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, userId); getTwitterDirectMessageSent(UserId, OAuth); getTwittwrDirectMessageRecieved(OAuth, UserId); getUserMentions(OAuth, itemTwt.TwitterUserId, Guid.Parse(UserId)); getUserFollowersData(OAuth, itemTwt.TwitterScreenName, itemTwt.TwitterUserId, Guid.Parse(UserId)); getUserRetweet(OAuth, itemTwt.TwitterUserId, Guid.Parse(UserId)); #region UpdateTeammemberprofile Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.ProfileName = itemTwt.TwitterScreenName; objTeamMemberProfile.ProfilePicUrl = itemTwt.ProfileImageUrl; objTeamMemberProfile.ProfileId = itemTwt.TwitterUserId; objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile); #endregion Domain.Socioboard.Domain.TwitterAccount _TwitterAccount = objTwtRepo.GetUserInformation(itemTwt.UserId, itemTwt.TwitterUserId); if (_TwitterAccount != null) getTwitterStats(_TwitterAccount); } return "twitter Info Updated Successfully"; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return ret; }
public void getTwitterEngagement(string UserId, oAuthTwitter OAuth) { #region Add Twitter Engagement Tweet objTweet = new Tweet(); TwitterEngagement objTwitterEngagement = new TwitterEngagement(); TwitterEngagementRepository objTwitterEngagementRepository = new TwitterEngagementRepository(); //TwitterMessageRepository objTwitterMessageRepository=new TwitterMessageRepository (); List<Domain.Socioboard.Domain.TwitterMessage> lsttwtmessage = objTwitterMessageRepository.getAllTwitterMessagesRetweet(Guid.Parse(UserId), objTwitterAccount.TwitterUserId); List<Domain.Socioboard.Domain.TwitterMessage> tsttwtwmessagetweet = objTwitterMessageRepository.getAllTwitterMessagestweet(Guid.Parse(UserId), objTwitterAccount.TwitterUserId); foreach (var itemmsg in lsttwtmessage) { JArray EngagementData = objTweet.Get_Statuses_RetweetsById(OAuth, itemmsg.MessageId); foreach (var item in EngagementData) { objTwitterEngagement.Id = Guid.NewGuid(); objTwitterEngagement.UserId = Guid.Parse(UserId); objTwitterEngagement.EntryDate = DateTime.Now; objTwitterEngagement.ProfileId = objTwitterAccount.TwitterUserId; try { objTwitterEngagement.RetweetCount = item["retweet_count"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterEngagement.ReplyCount = objTwitterMessageRepository.getReplyCountbyProfileId(objTwitterAccount.TwitterUserId, Guid.Parse(UserId)).ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterEngagement.Engagement = ((Int32.Parse(objTwitterEngagement.ReplyCount) + Int32.Parse(objTwitterEngagement.RetweetCount)) * 100 / (objTwitterAccount.FollowersCount)).ToString(); } catch (Exception ex) { objTwitterEngagement.Engagement = "0".ToString(); Console.WriteLine(ex.StackTrace); } try { objTwitterEngagement.Influence = (((tsttwtwmessagetweet.Count)) * 100 / (objTwitterAccount.FollowersCount)).ToString(); } catch (Exception ex) { objTwitterEngagement.Influence = "0".ToString(); Console.WriteLine(ex.StackTrace); } objTwitterEngagementRepository.Add(objTwitterEngagement); } } #endregion }
public void getTwitterMessages(string UserId, oAuthTwitter OAuth) { TwitterUser twtuser; #region Add Twitter Messages twtuser = new TwitterUser(); try { TimeLine tl = new TimeLine(); JArray data = null; try { data = tl.Get_Statuses_Mentions_Timeline(OAuth); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.StackTrace >> " + ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.Message >> " + ex.Message); } objTwitterMessage = new Domain.Socioboard.Domain.TwitterMessage(); foreach (var item in data) { objTwitterMessage.UserId = Guid.Parse(UserId); objTwitterMessage.Type = "twt_mentions"; objTwitterMessage.Id = Guid.NewGuid(); try { objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ScreenName = item["user"]["screen_name"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.EntryDate = DateTime.Now; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId)) { objTwitterMessageRepository.addTwitterMessage(objTwitterMessage); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.StackTrace >> " + ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.Message >> " + ex.Message); } #endregion }
public void getTwitterFeeds(string UserId, oAuthTwitter OAuth) { TwitterUser twtuser; #region Add Twitter User Feed twtuser = new TwitterUser(); try { JArray Home_Timeline = twtuser.GetStatuses_Home_Timeline(OAuth); objTwitterFeed = new Domain.Socioboard.Domain.TwitterFeed(); foreach (var item in Home_Timeline) { objTwitterFeed.UserId = Guid.Parse(UserId); objTwitterFeed.Type = "twt_feeds"; try { objTwitterFeed.Feed = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.ScreenName = objTwitterAccount.TwitterScreenName; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.ProfileId = objTwitterAccount.TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.FeedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.Id = Guid.NewGuid(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objTwitterFeed.EntryDate = DateTime.Now; try { objTwitterFeed.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterFeedRepository.checkTwitterFeedExists(objTwitterFeed.MessageId)) { try { objTwitterFeedRepository.addTwitterFeed(objTwitterFeed); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } } // Edited by Antima[20/12/2014] SentimentalAnalysis _SentimentalAnalysis = new SentimentalAnalysis(); FeedSentimentalAnalysisRepository _FeedSentimentalAnalysisRepository = new FeedSentimentalAnalysisRepository(); try { if (_FeedSentimentalAnalysisRepository.checkFeedExists(objTwitterFeed.ProfileId.ToString(), Guid.Parse(UserId), objTwitterFeed.Id.ToString())) { if (!string.IsNullOrEmpty(objTwitterFeed.Feed)) { string Network = "twitter"; _SentimentalAnalysis.GetPostSentimentsFromUclassify(Guid.Parse(UserId), objTwitterFeed.ProfileId, objTwitterFeed.MessageId, objTwitterFeed.Feed, Network); } } } catch (Exception) { } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("twtuser.GetStatuses_Home_Timeline ex.StackTrace >> " + ex.StackTrace); logger.Error("twtuser.GetStatuses_Home_Timeline ex.Message >> " + ex.Message); } #endregion }
private void getUserTweets(string UserId, oAuthTwitter OAuth) { #region Add User Tweets try { TwitterUser twtuser =new TwitterUser(); JArray Timeline = twtuser.GetStatuses_User_Timeline(OAuth); TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository(); TwitterMessage twtmsg = new TwitterMessage(); foreach (var item in Timeline) { objTwitterMessage.UserId = Guid.Parse(UserId); objTwitterMessage.Type = "twt_usertweets"; try { objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ScreenName = objTwitterAccount.TwitterScreenName; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.Id = Guid.NewGuid(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objTwitterMessage.EntryDate = DateTime.Now; try { objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId)) { objTwitterMessageRepository.addTwitterMessage(objTwitterMessage); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("twtuser.GetStatuses_User_Timeline ex.StackTrace >> " + ex.StackTrace); logger.Error("twtuser.GetStatuses_User_Timeline ex.Message >> " + ex.Message); } #endregion }
public string TwitterLogIn(string client_id, string client_secret, string redirect_uri, string requestToken, string requestSecret, string requestVerifier) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; Users userinfo = new Users(); oAuthTwitter OAuth = new oAuthTwitter(client_id, client_secret, redirect_uri); OAuth.AccessToken = requestToken; OAuth.AccessTokenSecret = requestVerifier; OAuth.AccessTokenGet(requestToken, requestVerifier); JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName); if (profile != null) { logger.Error("Twitter.asmx >> TwitterLogIn >> Twitter profile : " + profile); } else { logger.Error("Twitter.asmx >> TwitterLogIn >> NULL Twitter profile : " + profile); } string TwitterUserId = string.Empty; objTwitterAccount = new Domain.Socioboard.Domain.TwitterAccount(); Domain.Socioboard.Domain.User objUser = new Domain.Socioboard.Domain.User(); foreach (var item in profile) { #region Login Twitter Account try { objUser.ProfileUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } Console.WriteLine(er.StackTrace); } objUser.SocialLogin = "******" + TwitterUserId; try { objUser.UserName = item["name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion } return new JavaScriptSerializer().Serialize(objUser); }
public void getTwittwrDirectMessageRecieved(oAuthTwitter OAuth, string UserId) { #region Add Twitter Direct Message TwitterUser twtuser = new TwitterUser(); try { JArray Messages_Sent = twtuser.GetDirect_Messages(OAuth, 20); objTwitterDirectMessages = new Domain.Socioboard.Domain.TwitterDirectMessages(); foreach (var item in Messages_Sent) { objTwitterDirectMessages.UserId = Guid.Parse(UserId); objTwitterDirectMessages.Type = "twt_directmessages_received"; objTwitterDirectMessages.Id = Guid.NewGuid(); try { objTwitterDirectMessages.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.CreatedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.Message = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.RecipientId = item["recipient"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.RecipientScreenName = item["recipient"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.RecipientProfileUrl = item["recipient"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.SenderId = item["sender"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.SenderScreenName = item["sender"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.SenderProfileUrl = item["sender"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterDirectMessages.EntryDate = DateTime.Now; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterDirectMessageRepository.checkExistsDirectMessages(objTwitterDirectMessages.MessageId)) { try { objTwitterDirectMessageRepository.addNewDirectMessage(objTwitterDirectMessages); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("twtuser.GetDirect_Messages_Sent ex.StackTrace >> " + ex.StackTrace); logger.Error("twtuser.GetDirect_Messages_Sent ex.Message >> " + ex.Message); } #endregion }
public void getUserFollowersData(oAuthTwitter OAuth, string screeenName, string TwitterUserId, Guid userId) { try { TimeLine _TimeLine = new TimeLine(); JArray jdata = _TimeLine.Get_User_Followers(OAuth); JArray user_data = JArray.Parse(jdata[0]["users"].ToString()); Domain.Socioboard.Domain.InboxMessages _InboxMessages; foreach (var item in user_data) { try { _InboxMessages = new Domain.Socioboard.Domain.InboxMessages(); _InboxMessages.Id = Guid.NewGuid(); _InboxMessages.UserId = userId; _InboxMessages.ProfileId = TwitterUserId; _InboxMessages.ProfileType = "twt"; _InboxMessages.MessageType = "twt_followers"; _InboxMessages.EntryTime = DateTime.Now; _InboxMessages.MessageId = ""; _InboxMessages.Status = 0; try { _InboxMessages.Message = item["description"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message); } try { _InboxMessages.FromId = item["id_str"].ToString(); } catch (Exception ex) { _InboxMessages.FromId = item["id"].ToString(); } try { _InboxMessages.FromName = item["screen_name"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message); } try { _InboxMessages.FollowerCount = item["followers_count"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message); } try { _InboxMessages.FollowingCount = item["friends_count"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message); } try { _InboxMessages.FromImageUrl = item["profile_image_url"].ToString(); } catch (Exception ex) { _InboxMessages.FromImageUrl = item["profile_image_url_https"].ToString(); } try { _InboxMessages.CreatedTime = DateTime.Now; } catch (Exception ex) { logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message); } _InboxMessages.RecipientId = TwitterUserId; _InboxMessages.RecipientName = screeenName; if (!objInboxMessagesRepository.checkInboxMessageFriendExists(userId, _InboxMessages.FromId, _InboxMessages.RecipientId, _InboxMessages.MessageType)) { objInboxMessagesRepository.AddInboxMessages(_InboxMessages); } } catch (Exception ex) { logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message); } } } catch (Exception ex) { logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message); } }
public void getUserRetweet(oAuthTwitter OAuth, string TwitterUserId, Guid userId) { try { TimeLine _TimeLine = new TimeLine(); JArray jdata = _TimeLine.Get_Statuses_Retweet_Of_Me(OAuth); Domain.Socioboard.Domain.InboxMessages _InboxMessages; foreach (var item in jdata) { try { _InboxMessages = new Domain.Socioboard.Domain.InboxMessages(); _InboxMessages.UserId = userId; _InboxMessages.ProfileId = TwitterUserId; _InboxMessages.ProfileType = "twt"; _InboxMessages.MessageType = "twt_retweet"; _InboxMessages.EntryTime = DateTime.Now; try { _InboxMessages.MessageId = item["id_str"].ToString(); } catch (Exception ex) { _InboxMessages.MessageId = item["id"].ToString(); } try { _InboxMessages.Message = item["text"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message); } try { _InboxMessages.RecipientId = item["user"]["id_str"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message); } try { _InboxMessages.RecipientName = item["user"]["screen_name"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message); } try { _InboxMessages.RecipientImageUrl = item["user"]["profile_image_url"].ToString(); } catch (Exception ex) { _InboxMessages.RecipientImageUrl = item["user"]["profile_image_url_https"].ToString(); } Tweet _tweet = new Tweet(); JArray retweet_data = _tweet.Get_Statuses_RetweetsById(OAuth, _InboxMessages.MessageId); foreach (var item_retweet in retweet_data) { _InboxMessages.Id = Guid.NewGuid(); try { _InboxMessages.CreatedTime = Utility.ParseTwitterTime(item_retweet["created_at"].ToString()); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message); } try { _InboxMessages.FromId = item_retweet["user"]["id_str"].ToString(); } catch (Exception ex) { _InboxMessages.FromId = item_retweet["user"]["id"].ToString(); } try { _InboxMessages.FromName = item_retweet["user"]["screen_name"].ToString(); } catch (Exception ex) { logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message); } try { _InboxMessages.FromImageUrl = item_retweet["user"]["profile_image_url"].ToString(); } catch (Exception ex) { _InboxMessages.FromImageUrl = item_retweet["user"]["profile_image_url_https"].ToString(); } if (!objInboxMessagesRepository.checkInboxMessageRetweetExists(userId, _InboxMessages.MessageId, _InboxMessages.FromId, _InboxMessages.RecipientId, _InboxMessages.MessageType)) { objInboxMessagesRepository.AddInboxMessages(_InboxMessages); } } } catch (Exception ex) { logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message); } } } catch (Exception ex) { logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message); } }
public string TicketTwitterReply(string message, string profileid, string statusid) { Domain.Socioboard.Domain.TwitterAccount objTwitterAccount = objTwitterAccountRepository.getUserInformation(profileid); oAuthTwitter OAuthTwt = new oAuthTwitter(); OAuthTwt.AccessToken = objTwitterAccount.OAuthToken; OAuthTwt.AccessTokenSecret = objTwitterAccount.OAuthSecret; OAuthTwt.TwitterScreenName = objTwitterAccount.TwitterScreenName; OAuthTwt.TwitterUserId = objTwitterAccount.TwitterUserId; this.SetCofigDetailsForTwitter(OAuthTwt); Tweet twt = new Tweet(); JArray replypost = twt.Post_StatusesUpdate(OAuthTwt, message, statusid); return new JavaScriptSerializer().Serialize(replypost); }