public string contactSearchTwitter(string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { oAuthTwitter oauth = new oAuthTwitter(); Twitter obj = new Twitter(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); ArrayList alst = twtAccRepo.getAllTwitterAccounts(); foreach (Domain.Socioboard.Domain.TwitterAccount item in alst) { oauth.AccessToken = item.OAuthToken; oauth.AccessTokenSecret = item.OAuthSecret; oauth.TwitterUserId = item.TwitterUserId; oauth.TwitterScreenName = item.TwitterScreenName; obj.SetCofigDetailsForTwitter(oauth); if (this.CheckTwitterToken(oauth, keyword)) { break; } } Users twtUser = new Users(); JArray twitterSearchResult = twtUser.Get_Users_Search(oauth, keyword, "20"); foreach (var item in twitterSearchResult) { try { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.FromId = item["screen_name"].ToString(); objDiscoverySearch.FromName = item["screen_name"].ToString(); objDiscoverySearch.SearchKeyword = keyword; lstDiscoverySearch.Add(objDiscoverySearch); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } return(new JavaScriptSerializer().Serialize(lstDiscoverySearch)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please try Again")); } }
public string GetAllTwitterAccounts() { try { ArrayList lstTwtAcc = objTwitterAccountRepository.getAllTwitterAccounts(); return(new JavaScriptSerializer().Serialize(lstTwtAcc)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return("Something Went Wrong"); } }
public string DiscoverySearchTwitter(string UserId, string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { oAuthTwitter oauth = new oAuthTwitter(); Twitter obj = new Twitter(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); ArrayList alst = twtAccRepo.getAllTwitterAccounts(); foreach (Domain.Socioboard.Domain.TwitterAccount item in alst) { oauth.AccessToken = item.OAuthToken; oauth.AccessTokenSecret = item.OAuthSecret; oauth.TwitterUserId = item.TwitterUserId; oauth.TwitterScreenName = item.TwitterScreenName; obj.SetCofigDetailsForTwitter(oauth); if (this.CheckTwitterToken(oauth, keyword)) { 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 { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.CreatedTime = Utility.ParseTwitterTime(chile["created_at"].ToString().TrimStart('"').TrimEnd('"'));; objDiscoverySearch.EntryDate = DateTime.Now; objDiscoverySearch.FromId = chile["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.FromName = chile["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.ProfileImageUrl = chile["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.SearchKeyword = keyword; objDiscoverySearch.Network = "twitter"; objDiscoverySearch.Message = chile["text"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.MessageId = chile["id_str"].ToString().TrimStart('"').TrimEnd('"'); objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); string postID = chile["id"].ToString(); string postURL = "https://twitter.com/" + objDiscoverySearch.FromName + "/status/" + postID; if (!dissearchrepo.isKeywordPresent(objDiscoverySearch.SearchKeyword, objDiscoverySearch.MessageId)) { dissearchrepo.addNewSearchResult(objDiscoverySearch); } lstDiscoverySearch.Add(objDiscoverySearch); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } return(new JavaScriptSerializer().Serialize(lstDiscoverySearch)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please try Again")); } }