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 void ScraperHasTage(ref FacebookUser fbUser, string Hash, Guid BoardfbPageId) //{ // GlobusHttpHelper HttpHelper = fbUser.globusHttpHelper; // string KeyWord = Hash; // string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord)); // List<string> pageSouceSplit = new List<string>(); // string[] trendingArr = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "li data-topicid="); // string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "uiLikePageButton"); // foreach (var item in PagesLink) // { // pageSouceSplit.Add(item); // } // PagesLink = PagesLink.Skip(1).ToArray(); // foreach (var item_pageSouceSplit in pageSouceSplit) // { // try // { // if (item_pageSouceSplit.Contains("<!DOCTYPE html>")) // { // continue; // } // Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit); // Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds(); // fbfeed.Id = Guid.NewGuid(); // fbfeed.Isvisible = true; // fbfeed.Message = listContent["Message"]; // fbfeed.Image = listContent["PostImage"]; // fbfeed.Description = listContent["Title"]; // string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at"); // string d = splitdate[0].Trim(); // string t = splitdate[1].Trim(); // fbfeed.Createddate = Convert.ToDateTime(d + " " + t); // fbfeed.Feedid = listContent["PostId"]; // fbfeed.Type = listContent["Type"]; // fbfeed.Type = listContent["Link"]; // fbfeed.Fbpageprofileid = BoardfbPageId; // if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId)) // { // boardrepo.addBoardFbPageFeed(fbfeed); // } // // Please Write Code get Dictionary data // // // } // catch { }; // } // try // { // string ajaxpipe_token = Utils.getBetween(pageSource_Home, "\"ajaxpipe_token\":\"", "\""); // string[] data_c = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "data-cursor="); // string cursor = Utils.getBetween(data_c[4], "\"", "="); // if (cursor.Contains("data-dedupekey")) // { // cursor = "-" + cursor; // cursor = Utils.getBetween(cursor, "-", "\""); // } // string sectionid = Utils.getBetween(pageSource_Home, "section_id\\\":", ","); // string userid = Utils.getBetween(pageSource_Home, "USER_ID\":\"", "\""); // string feed_Id = "90842368"; // string pager_id = "u_ps_0_0_1n"; // for (int i = 2; i < 50; i++) // { // try // { // Thread.Sleep(30 * 1000); // List<string> pageSouceSplitPagination = new List<string>(); // if (string.IsNullOrEmpty(fbUser.username)) // { // break; // } // //GlobusLogHelper.log.Info("Please wait... Searching for data from Page :" + i + " with User Name : " + fbUser.username); // string req = "https://www.facebook.com/ajax/pagelet/generic.php/LitestandMoreStoriesPagelet?ajaxpipe=1&ajaxpipe_token=" + ajaxpipe_token + "&no_script_path=1&data=%7B%22cursor%22%3A%22" + cursor + "%22%2C%22preload_next_cursor%22%3Anull%2C%22pager_config%22%3A%22%7B%5C%22edge%5C%22%3Anull%2C%5C%22source_id%5C%22%3Anull%2C%5C%22section_id%5C%22%3A" + sectionid + "%2C%5C%22pause_at%5C%22%3Anull%2C%5C%22stream_id%5C%22%3Anull%2C%5C%22section_type%5C%22%3A1%2C%5C%22sizes%5C%22%3Anull%2C%5C%22most_recent%5C%22%3Afalse%2C%5C%22unread_session%5C%22%3Afalse%2C%5C%22continue_top_news_feed%5C%22%3Afalse%2C%5C%22ranking_model%5C%22%3Anull%2C%5C%22unread_only%5C%22%3Afalse%7D%22%2C%22pager_id%22%3A%22" + pager_id + "%22%2C%22scroll_count%22%3A1%2C%22start_unread_session%22%3Afalse%2C%22start_continue_top_news_feed%22%3Afalse%2C%22feed_stream_id%22%3A" + feed_Id + "%2C%22snapshot_time%22%3Anull%7D&__user="******"&__a=1&__dyn=7nm8RW8BgCBynzpQ9UoHaEWCueyrhEK49oKiWFaaBGeqrYw8popyujhElx2ubhHximmey8szoyfwgo&__req=jsonp_2&__rev=1583304&__adt=" + i + ""; // // string respReq = HttpHelper.getHtmlfromUrl(new Uri(req)); // respReq = respReq.Replace("\\", "").Replace("u003C", "<"); // string[] arrrespReq = System.Text.RegularExpressions.Regex.Split(respReq, "source_id"); // feed_Id = Utils.getBetween(respReq, "feed_stream_id", "snapshot_time"); // feed_Id = Utils.getBetween(feed_Id, "A", "u"); // string[] pager_id1 = System.Text.RegularExpressions.Regex.Split(respReq, "_4-u2 mbl "); // pager_id = Utils.getBetween(pager_id1[2], "id=\"", "\""); // data_c = System.Text.RegularExpressions.Regex.Split(respReq, "data-cursor="); // if (data_c.Length < 8) // { // cursor = Utils.getBetween(data_c[data_c.Length - 1], "\"", "="); // } // cursor = Utils.getBetween(data_c[8], "\"", "="); // if (cursor.Contains("data-dedupekey")) // { // cursor = "-" + cursor; // cursor = Utils.getBetween(cursor, "-", "\""); // } // string[] PagesLinkPagination = System.Text.RegularExpressions.Regex.Split(respReq, "<span>Suggested Post</span>"); // foreach (var item in PagesLinkPagination) // { // pageSouceSplitPagination.Add(item); // } // PagesLink = System.Text.RegularExpressions.Regex.Split(respReq, "uiLikePageButton"); // foreach (var item in PagesLink) // { // pageSouceSplitPagination.Add(item); // } // foreach (var item_pageSouceSplit in pageSouceSplit) // { // try // { // if (item_pageSouceSplit.Contains("<!DOCTYPE html>")) // { // continue; // } // Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit); // Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds(); // fbfeed.Id = Guid.NewGuid(); // fbfeed.Isvisible = true; // fbfeed.Message = listContent["Message"]; // fbfeed.Image = listContent["PostImage"]; // fbfeed.Description = listContent["Title"]; // string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at"); // string d = splitdate[0].Trim(); // string t = splitdate[1].Trim(); // fbfeed.Createddate = Convert.ToDateTime(d + " " + t); // fbfeed.Feedid = listContent["PostId"]; // fbfeed.Type = listContent["Type"]; // fbfeed.Type = listContent["Link"]; // fbfeed.Fbpageprofileid = BoardfbPageId; // if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId)) // { // boardrepo.addBoardFbPageFeed(fbfeed); // } // // Please Write Code get Dictionary data // // // } // catch { }; // } // } // catch (Exception ex) // { //GlobusLogHelper.log.Error(ex.StackTrace); // } // } // } // catch // { } //} //public Dictionary<string, string> ScrapHasTagPages(string Value) //{ // string redirectionHref = string.Empty; // string title = string.Empty; // List<string[]> Likedata = new List<string[]>(); // Dictionary<string, string> HasTagData = new Dictionary<string, string>(); // // foreach (var Value in Likepages) // { // try // { // redirectionHref = Utils.getBetween(Value, "href=\"", "\""); // string profileUrl = redirectionHref;//1 // if (redirectionHref.Contains("https://www.facebook.com")) // { // string[] Arr_Title = System.Text.RegularExpressions.Regex.Split(Value, "<span class=\"fwb fcg\""); // foreach (var valuetitle in Arr_Title) // { // try // { // // title = Utils.getBetween(valuetitle, "<a", "/a>"); // title = Utils.getBetween(valuetitle, "\">", "/a>"); // if (!title.Equals(string.Empty)) // { // title = Utils.getBetween(title, "\">", "<"); // if (!string.IsNullOrEmpty(title)) // { // break; // } // } // } // catch (Exception) // { // } // } // string profileName = title;//2 // string Message = Utils.getBetween(Value, "<p>", "<").Replace("@", "@").Replace("&", "&").Replace("u0025", "%");//7 // string[] timeDetails = Regex.Split(Value, "<abbr"); // string postedTime = string.Empty; // try // { // postedTime = Utils.getBetween(timeDetails[1], "=\"", "\""); // } // catch { }; // string postid = string.Empty; // try // { // postid = Utils.getBetween(timeDetails[0], "fbid=", "&"); // if (postid == "") // { // postid = Utils.getBetween(timeDetails[0], "/posts/", "\" target="); // } // } // catch // { // } // string[] DetailedInfo = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"_6m7\">"); // string detail = string.Empty; // try // { // detail = "-" + DetailedInfo[1];//8 // detail = Utils.getBetween(detail, "-", "</div>").Replace("&", "&").Replace("u0025", "%"); // if (detail.Contains("<a ")) // { // string GetVisitUrl = Utils.getBetween(detail, "\">", "</a>"); // detail = Utils.getBetween("$$$####" + detail, "$$$####", "<a href=") + "-" + GetVisitUrl; // } // } // catch // { }; // string[] ArrDetail = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"mbs _6m6\">"); // string Titles = string.Empty; // // string Url = Utils.getBetween(ArrDetail[0], "", ""); // try // { // Titles = Utils.getBetween(ArrDetail[1], ">", "</a>").Replace("@", "@").Replace("&", "&").Replace("u0025", "%");//6 // if (Titles.Contains("Sachin Tendulkar")) // { // } // } // catch { }; // string SiteRedirectionUrl = string.Empty; // try // { // SiteRedirectionUrl = Utils.getBetween(ArrDetail[1], "LinkshimAsyncLink.swap(this, "", ");"); // } // catch { }; // try // { // SiteRedirectionUrl = Uri.UnescapeDataString(SiteRedirectionUrl).Replace("\\u0025", "%").Replace("\\", "");//4 // } // catch { }; // string websiteUrl = string.Empty; // try // { // websiteUrl = Utils.getBetween(SiteRedirectionUrl, "//", "/"); // } // catch { }; // string redirectionImg = string.Empty; // try // { // string[] adImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"scaledImageFitWidth img\""); // redirectionImg = Utils.getBetween(adImg[1], "src=\"", "\"").Replace("&", "&"); // } // catch { }; // string[] profImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"_s0 5xib 5sq7 _rw img\""); // string profileImg = string.Empty; // try // { // profileImg = Utils.getBetween(profImg[0], "src=\"", "\"").Replace("&", "&"); // } // catch { }; // HasTagData.Add("Title", title); // HasTagData.Add("Time", postedTime); // HasTagData.Add("Type", "link"); // HasTagData.Add("Message", Message); // HasTagData.Add("Image", profileImg); // HasTagData.Add("PostImage", redirectionImg); // HasTagData.Add("PostId", postid); // HasTagData.Add("Link", SiteRedirectionUrl); // } // } // catch { }; // } // return HasTagData; //} public static List <Domain.Socioboard.Domain.DiscoverySearch> ScraperHasTage(string Hash) { GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); string KeyWord = Hash; string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord)); List <string> pageSouceSplit = new List <string>(); string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "_4-u2 mbm _5jmm _5pat _5v3q _4-u8"); foreach (var item in PagesLink) { pageSouceSplit.Add(item); } PagesLink = PagesLink.Skip(1).ToArray(); List <Domain.Socioboard.Domain.DiscoverySearch> discSearchList = new List <Domain.Socioboard.Domain.DiscoverySearch>(); foreach (var item_pageSouceSplit in pageSouceSplit) { Domain.Socioboard.Domain.DiscoverySearch discSearchObj = new Domain.Socioboard.Domain.DiscoverySearch(); try { if (item_pageSouceSplit.Contains("<!DOCTYPE html>")) { continue; } Dictionary <string, string> listContent = ScrapHasTagPages(item_pageSouceSplit); // Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds(); discSearchObj.Id = Guid.NewGuid(); discSearchObj.Message = listContent["Message"]; //discSearchObj.Image = listContent["PostImage"]; //discSearchObj.Description = listContent["Title"]; string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at"); string d = splitdate[0].Trim(); string t = splitdate[1].Trim(); discSearchObj.CreatedTime = Convert.ToDateTime(d + " " + t); discSearchObj.MessageId = listContent["PostId"]; //discSearchObj.Type = listContent["Type"]; //discSearchObj.Link = listContent["Link"]; discSearchObj.FromId = listContent["FromId"]; discSearchObj.FromName = listContent["FromName"]; //discSearchObj.Fbpageprofileid = BoardfbPageId; discSearchList.Add(discSearchObj); } catch { }; } return(discSearchList); }
public string ContactSearchInstagram(string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); //Domain.Socioboard.Domain.InstagramAccount _InstagramAccount = _InstagramAccountRepository.GetInstagramAccount(); GlobusInstagramLib.Instagram.Core.UsersMethods.Users _user = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); string Client_id = ConfigurationManager.AppSettings["InstagramClientKey"].ToString(); string ret = _user.UsersSearch(keyword, "", "", Client_id); JObject _JObject = JObject.Parse(ret); foreach (var item in _JObject["data"]) { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.FromId = item["id"].ToString(); objDiscoverySearch.FromName = item["username"].ToString(); objDiscoverySearch.ProfileImageUrl = item["profile_picture"].ToString(); lstDiscoverySearch.Add(objDiscoverySearch); } return(new JavaScriptSerializer().Serialize(lstDiscoverySearch)); }
public string DiscoverySearchGplus(string UserId, string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> GplusDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { string searchResultObj = GplusDiscoverySearchHelper.GooglePlus(keyword); GooglePlusAccountRepository gplusAccRepo = new GooglePlusAccountRepository(); ArrayList alst = gplusAccRepo.getAllGooglePlusAccounts(); GlobusGooglePlusLib.Authentication.oAuthToken oauth = new GlobusGooglePlusLib.Authentication.oAuthToken(); GooglePlusActivities obj = new GooglePlusActivities(); JObject GplusActivities = JObject.Parse(GplusDiscoverySearchHelper.GooglePlus(keyword)); foreach (JObject gobj in JArray.Parse(GplusActivities["items"].ToString())) { Domain.Socioboard.Domain.DiscoverySearch gpfeed = new Domain.Socioboard.Domain.DiscoverySearch(); gpfeed.Id = Guid.NewGuid(); try { gpfeed.MessageId = gobj["url"].ToString(); gpfeed.CreatedTime = DateTime.Parse(gobj["published"].ToString()); gpfeed.Message = gobj["title"].ToString(); gpfeed.FromId = gobj["actor"]["id"].ToString(); gpfeed.FromName = gobj["actor"]["displayName"].ToString(); gpfeed.ProfileImageUrl = gobj["actor"]["image"]["url"].ToString(); } catch { } GplusDiscoverySearch.Add(gpfeed); } } catch { } return(new JavaScriptSerializer().Serialize(GplusDiscoverySearch)); }
public string contactSearchFacebook(string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { FacebookAccountRepository fbAccRepo = new FacebookAccountRepository(); List <Domain.Socioboard.Domain.FacebookAccount> asltFbAccount = fbAccRepo.getFbAccounts(); string accesstoken = string.Empty; foreach (Domain.Socioboard.Domain.FacebookAccount item in asltFbAccount) { try { FacebookClient fb = new FacebookClient(); fb.AccessToken = item.AccessToken; dynamic me = fb.Get("v2.0/me"); string id = me["id"].ToString(); accesstoken = item.AccessToken; break; } catch (Exception ex) { } } //string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100"; string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &limit=20&type=user&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 { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.FromId = chile["id"].ToString(); objDiscoverySearch.FromName = chile["name"].ToString(); 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 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(); List <Domain.Socioboard.Domain.TwitterAccount> alst = twtAccRepo.getTwtAccount(); try { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.SearchKeyword = keyword; objDiscoverySearch.Network = "twitter"; objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); if (!dissearchrepo.isKeywordPresentforNetwork(objDiscoverySearch.SearchKeyword, objDiscoverySearch.Network)) { dissearchrepo.addNewSearchResult(objDiscoverySearch); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } 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); try { Users _Users = new Users(); JArray _AccountVerify = _Users.Get_Account_Verify_Credentials(oauth); string id = _AccountVerify["id_str"].ToString(); break; } catch (Exception ex) { } //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); 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 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 contactSearchFacebook(string keyword) { List<Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { FacebookAccountRepository fbAccRepo = new FacebookAccountRepository(); ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts(); string accesstoken = string.Empty; foreach (Domain.Socioboard.Domain.FacebookAccount item in asltFbAccount) { if (item.AccessToken != "") { accesstoken = item.AccessToken; if (this.CheckFacebookToken(accesstoken, keyword)) { break; } } } //string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100"; string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &limit=20&type=user&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 { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.FromId = chile["id"].ToString(); objDiscoverySearch.FromName = chile["name"].ToString(); 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 DiscoverySearchFacebook(string UserId, string keyword) { List<Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { // lstDiscoverySearch = dissearchrepo.GetAllSearchKeywordsByUserId(Guid.Parse(UserId), keyword, "facebook"); FacebookAccountRepository fbAccRepo = new FacebookAccountRepository(); ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts(); string accesstoken = string.Empty; #region Added Sumit Gupta [27/01/15] foreach (Domain.Socioboard.Domain.FacebookAccount item in asltFbAccount) { accesstoken = item.AccessToken; if (this.CheckFacebookToken(accesstoken, keyword)) { break; } } #endregion ////Access Token HARD CODED temporarily //accesstoken = "CAAKMrAl97iIBAD9MqfWtfjIxwFVteGCLVZBsoHpc1TZCH8Kf3KQuMebkbNYLb282cUTisu6iGZBiZAzzwxWvDhh20vCzs5mZCFZBblZBXu40BQisUjoOCZARUQklHBiK3Cx7DOgdXtbvupC4xJ1VpPjKspwiZBRzNYncjgQAyUqd5sGsXUDHcqKy0UBYkmbfq7QZCFgpyG5icOPeMhRb4TXJaic7UF7B1WHLhw2A5EW0kb3AZDZD"; string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100"; 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 { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.SearchKeyword = keyword; objDiscoverySearch.Network = "facebook"; objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); if (!dissearchrepo.isKeywordPresentforNetwork(objDiscoverySearch.SearchKeyword, objDiscoverySearch.Network)) { dissearchrepo.addNewSearchResult(objDiscoverySearch); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { Domain.Socioboard.Domain.DiscoverySearch objSearchHistory = new Domain.Socioboard.Domain.DiscoverySearch(); objSearchHistory.CreatedTime = DateTime.Parse(chile["created_time"].ToString()); objSearchHistory.EntryDate = DateTime.Now; objSearchHistory.FromId = chile["from"]["id"].ToString(); try { objSearchHistory.FromName = chile["from"]["name"].ToString(); } catch { } try { objSearchHistory.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small"; } catch { } objSearchHistory.SearchKeyword = keyword; objSearchHistory.Network = "facebook"; try { objSearchHistory.Message = chile["message"].ToString(); } catch { } try { objSearchHistory.MessageId = chile["id"].ToString(); } catch { } objSearchHistory.Id = Guid.NewGuid(); objSearchHistory.UserId = Guid.Parse(UserId); lstDiscoverySearch.Add(objSearchHistory); } catch { } } } return new JavaScriptSerializer().Serialize(lstDiscoverySearch); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return new JavaScriptSerializer().Serialize("Please try Again"); } }
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.SearchKeyword = keyword; objDiscoverySearch.Network = "twitter"; objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); if (!dissearchrepo.isKeywordPresentforNetwork(objDiscoverySearch.SearchKeyword, objDiscoverySearch.Network)) { dissearchrepo.addNewSearchResult(objDiscoverySearch); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } 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); 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 void ScraperHasTage(ref FacebookUser fbUser, string Hash, Guid BoardfbPageId) //{ // GlobusHttpHelper HttpHelper = fbUser.globusHttpHelper; // string KeyWord = Hash; // string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord)); // List<string> pageSouceSplit = new List<string>(); // string[] trendingArr = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "li data-topicid="); // string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "uiLikePageButton"); // foreach (var item in PagesLink) // { // pageSouceSplit.Add(item); // } // PagesLink = PagesLink.Skip(1).ToArray(); // foreach (var item_pageSouceSplit in pageSouceSplit) // { // try // { // if (item_pageSouceSplit.Contains("<!DOCTYPE html>")) // { // continue; // } // Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit); // Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds(); // fbfeed.Id = Guid.NewGuid(); // fbfeed.Isvisible = true; // fbfeed.Message = listContent["Message"]; // fbfeed.Image = listContent["PostImage"]; // fbfeed.Description = listContent["Title"]; // string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at"); // string d = splitdate[0].Trim(); // string t = splitdate[1].Trim(); // fbfeed.Createddate = Convert.ToDateTime(d + " " + t); // fbfeed.Feedid = listContent["PostId"]; // fbfeed.Type = listContent["Type"]; // fbfeed.Type = listContent["Link"]; // fbfeed.Fbpageprofileid = BoardfbPageId; // if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId)) // { // boardrepo.addBoardFbPageFeed(fbfeed); // } // // Please Write Code get Dictionary data // // // } // catch { }; // } // try // { // string ajaxpipe_token = Utils.getBetween(pageSource_Home, "\"ajaxpipe_token\":\"", "\""); // string[] data_c = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "data-cursor="); // string cursor = Utils.getBetween(data_c[4], "\"", "="); // if (cursor.Contains("data-dedupekey")) // { // cursor = "-" + cursor; // cursor = Utils.getBetween(cursor, "-", "\""); // } // string sectionid = Utils.getBetween(pageSource_Home, "section_id\\\":", ","); // string userid = Utils.getBetween(pageSource_Home, "USER_ID\":\"", "\""); // string feed_Id = "90842368"; // string pager_id = "u_ps_0_0_1n"; // for (int i = 2; i < 50; i++) // { // try // { // Thread.Sleep(30 * 1000); // List<string> pageSouceSplitPagination = new List<string>(); // if (string.IsNullOrEmpty(fbUser.username)) // { // break; // } // //GlobusLogHelper.log.Info("Please wait... Searching for data from Page :" + i + " with User Name : " + fbUser.username); // string req = "https://www.facebook.com/ajax/pagelet/generic.php/LitestandMoreStoriesPagelet?ajaxpipe=1&ajaxpipe_token=" + ajaxpipe_token + "&no_script_path=1&data=%7B%22cursor%22%3A%22" + cursor + "%22%2C%22preload_next_cursor%22%3Anull%2C%22pager_config%22%3A%22%7B%5C%22edge%5C%22%3Anull%2C%5C%22source_id%5C%22%3Anull%2C%5C%22section_id%5C%22%3A" + sectionid + "%2C%5C%22pause_at%5C%22%3Anull%2C%5C%22stream_id%5C%22%3Anull%2C%5C%22section_type%5C%22%3A1%2C%5C%22sizes%5C%22%3Anull%2C%5C%22most_recent%5C%22%3Afalse%2C%5C%22unread_session%5C%22%3Afalse%2C%5C%22continue_top_news_feed%5C%22%3Afalse%2C%5C%22ranking_model%5C%22%3Anull%2C%5C%22unread_only%5C%22%3Afalse%7D%22%2C%22pager_id%22%3A%22" + pager_id + "%22%2C%22scroll_count%22%3A1%2C%22start_unread_session%22%3Afalse%2C%22start_continue_top_news_feed%22%3Afalse%2C%22feed_stream_id%22%3A" + feed_Id + "%2C%22snapshot_time%22%3Anull%7D&__user="******"&__a=1&__dyn=7nm8RW8BgCBynzpQ9UoHaEWCueyrhEK49oKiWFaaBGeqrYw8popyujhElx2ubhHximmey8szoyfwgo&__req=jsonp_2&__rev=1583304&__adt=" + i + ""; // // string respReq = HttpHelper.getHtmlfromUrl(new Uri(req)); // respReq = respReq.Replace("\\", "").Replace("u003C", "<"); // string[] arrrespReq = System.Text.RegularExpressions.Regex.Split(respReq, "source_id"); // feed_Id = Utils.getBetween(respReq, "feed_stream_id", "snapshot_time"); // feed_Id = Utils.getBetween(feed_Id, "A", "u"); // string[] pager_id1 = System.Text.RegularExpressions.Regex.Split(respReq, "_4-u2 mbl "); // pager_id = Utils.getBetween(pager_id1[2], "id=\"", "\""); // data_c = System.Text.RegularExpressions.Regex.Split(respReq, "data-cursor="); // if (data_c.Length < 8) // { // cursor = Utils.getBetween(data_c[data_c.Length - 1], "\"", "="); // } // cursor = Utils.getBetween(data_c[8], "\"", "="); // if (cursor.Contains("data-dedupekey")) // { // cursor = "-" + cursor; // cursor = Utils.getBetween(cursor, "-", "\""); // } // string[] PagesLinkPagination = System.Text.RegularExpressions.Regex.Split(respReq, "<span>Suggested Post</span>"); // foreach (var item in PagesLinkPagination) // { // pageSouceSplitPagination.Add(item); // } // PagesLink = System.Text.RegularExpressions.Regex.Split(respReq, "uiLikePageButton"); // foreach (var item in PagesLink) // { // pageSouceSplitPagination.Add(item); // } // foreach (var item_pageSouceSplit in pageSouceSplit) // { // try // { // if (item_pageSouceSplit.Contains("<!DOCTYPE html>")) // { // continue; // } // Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit); // Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds(); // fbfeed.Id = Guid.NewGuid(); // fbfeed.Isvisible = true; // fbfeed.Message = listContent["Message"]; // fbfeed.Image = listContent["PostImage"]; // fbfeed.Description = listContent["Title"]; // string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at"); // string d = splitdate[0].Trim(); // string t = splitdate[1].Trim(); // fbfeed.Createddate = Convert.ToDateTime(d + " " + t); // fbfeed.Feedid = listContent["PostId"]; // fbfeed.Type = listContent["Type"]; // fbfeed.Type = listContent["Link"]; // fbfeed.Fbpageprofileid = BoardfbPageId; // if (!boardrepo.checkFacebookFeedExists(fbfeed.Feedid, BoardfbPageId)) // { // boardrepo.addBoardFbPageFeed(fbfeed); // } // // Please Write Code get Dictionary data // // // } // catch { }; // } // } // catch (Exception ex) // { //GlobusLogHelper.log.Error(ex.StackTrace); // } // } // } // catch // { } //} //public Dictionary<string, string> ScrapHasTagPages(string Value) //{ // string redirectionHref = string.Empty; // string title = string.Empty; // List<string[]> Likedata = new List<string[]>(); // Dictionary<string, string> HasTagData = new Dictionary<string, string>(); // // foreach (var Value in Likepages) // { // try // { // redirectionHref = Utils.getBetween(Value, "href=\"", "\""); // string profileUrl = redirectionHref;//1 // if (redirectionHref.Contains("https://www.facebook.com")) // { // string[] Arr_Title = System.Text.RegularExpressions.Regex.Split(Value, "<span class=\"fwb fcg\""); // foreach (var valuetitle in Arr_Title) // { // try // { // // title = Utils.getBetween(valuetitle, "<a", "/a>"); // title = Utils.getBetween(valuetitle, "\">", "/a>"); // if (!title.Equals(string.Empty)) // { // title = Utils.getBetween(title, "\">", "<"); // if (!string.IsNullOrEmpty(title)) // { // break; // } // } // } // catch (Exception) // { // } // } // string profileName = title;//2 // string Message = Utils.getBetween(Value, "<p>", "<").Replace("@", "@").Replace("&", "&").Replace("u0025", "%");//7 // string[] timeDetails = Regex.Split(Value, "<abbr"); // string postedTime = string.Empty; // try // { // postedTime = Utils.getBetween(timeDetails[1], "=\"", "\""); // } // catch { }; // string postid = string.Empty; // try // { // postid = Utils.getBetween(timeDetails[0], "fbid=", "&"); // if (postid == "") // { // postid = Utils.getBetween(timeDetails[0], "/posts/", "\" target="); // } // } // catch // { // } // string[] DetailedInfo = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"_6m7\">"); // string detail = string.Empty; // try // { // detail = "-" + DetailedInfo[1];//8 // detail = Utils.getBetween(detail, "-", "</div>").Replace("&", "&").Replace("u0025", "%"); // if (detail.Contains("<a ")) // { // string GetVisitUrl = Utils.getBetween(detail, "\">", "</a>"); // detail = Utils.getBetween("$$$####" + detail, "$$$####", "<a href=") + "-" + GetVisitUrl; // } // } // catch // { }; // string[] ArrDetail = System.Text.RegularExpressions.Regex.Split(Value, "<div class=\"mbs _6m6\">"); // string Titles = string.Empty; // // string Url = Utils.getBetween(ArrDetail[0], "", ""); // try // { // Titles = Utils.getBetween(ArrDetail[1], ">", "</a>").Replace("@", "@").Replace("&", "&").Replace("u0025", "%");//6 // if (Titles.Contains("Sachin Tendulkar")) // { // } // } // catch { }; // string SiteRedirectionUrl = string.Empty; // try // { // SiteRedirectionUrl = Utils.getBetween(ArrDetail[1], "LinkshimAsyncLink.swap(this, "", ");"); // } // catch { }; // try // { // SiteRedirectionUrl = Uri.UnescapeDataString(SiteRedirectionUrl).Replace("\\u0025", "%").Replace("\\", "");//4 // } // catch { }; // string websiteUrl = string.Empty; // try // { // websiteUrl = Utils.getBetween(SiteRedirectionUrl, "//", "/"); // } // catch { }; // string redirectionImg = string.Empty; // try // { // string[] adImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"scaledImageFitWidth img\""); // redirectionImg = Utils.getBetween(adImg[1], "src=\"", "\"").Replace("&", "&"); // } // catch { }; // string[] profImg = System.Text.RegularExpressions.Regex.Split(Value, "<img class=\"_s0 5xib 5sq7 _rw img\""); // string profileImg = string.Empty; // try // { // profileImg = Utils.getBetween(profImg[0], "src=\"", "\"").Replace("&", "&"); // } // catch { }; // HasTagData.Add("Title", title); // HasTagData.Add("Time", postedTime); // HasTagData.Add("Type", "link"); // HasTagData.Add("Message", Message); // HasTagData.Add("Image", profileImg); // HasTagData.Add("PostImage", redirectionImg); // HasTagData.Add("PostId", postid); // HasTagData.Add("Link", SiteRedirectionUrl); // } // } // catch { }; // } // return HasTagData; //} public static List<Domain.Socioboard.Domain.DiscoverySearch> ScraperHasTage(string Hash) { GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); string KeyWord = Hash; string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/hashtag/" + KeyWord)); List<string> pageSouceSplit = new List<string>(); string[] PagesLink = System.Text.RegularExpressions.Regex.Split(pageSource_Home, "_4-u2 mbm _5jmm _5pat _5v3q _4-u8"); foreach (var item in PagesLink) { pageSouceSplit.Add(item); } PagesLink = PagesLink.Skip(1).ToArray(); List<Domain.Socioboard.Domain.DiscoverySearch> discSearchList = new List<Domain.Socioboard.Domain.DiscoverySearch>(); foreach (var item_pageSouceSplit in pageSouceSplit) { Domain.Socioboard.Domain.DiscoverySearch discSearchObj = new Domain.Socioboard.Domain.DiscoverySearch(); try { if (item_pageSouceSplit.Contains("<!DOCTYPE html>")) { continue; } Dictionary<string, string> listContent = ScrapHasTagPages(item_pageSouceSplit); // Domain.Socioboard.Domain.Boardfbfeeds fbfeed = new Domain.Socioboard.Domain.Boardfbfeeds(); discSearchObj.Id = Guid.NewGuid(); discSearchObj.Message = listContent["Message"]; //discSearchObj.Image = listContent["PostImage"]; //discSearchObj.Description = listContent["Title"]; string[] splitdate = System.Text.RegularExpressions.Regex.Split(listContent["Time"], "at"); string d = splitdate[0].Trim(); string t = splitdate[1].Trim(); discSearchObj.CreatedTime = Convert.ToDateTime(d + " " + t); discSearchObj.MessageId = listContent["PostId"]; //discSearchObj.Type = listContent["Type"]; //discSearchObj.Link = listContent["Link"]; discSearchObj.FromId = listContent["FromId"]; discSearchObj.FromName = listContent["FromName"]; //discSearchObj.Fbpageprofileid = BoardfbPageId; discSearchList.Add(discSearchObj); } catch { }; } return discSearchList; }
public string ContactSearchInstagram(string keyword) { List<Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Socioboard.Domain.DiscoverySearch>(); //Domain.Socioboard.Domain.InstagramAccount _InstagramAccount = _InstagramAccountRepository.GetInstagramAccount(); GlobusInstagramLib.Instagram.Core.UsersMethods.Users _user = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users(); string Client_id = ConfigurationManager.AppSettings["InstagramClientKey"].ToString(); string ret = _user.UsersSearch(keyword, "", "", Client_id); JObject _JObject = JObject.Parse(ret); foreach (var item in _JObject["data"]) { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.FromId = item["id"].ToString(); objDiscoverySearch.FromName = item["username"].ToString(); objDiscoverySearch.ProfileImageUrl = item["profile_picture"].ToString(); lstDiscoverySearch.Add(objDiscoverySearch); } return new JavaScriptSerializer().Serialize(lstDiscoverySearch); }
public string DiscoverySearchGplus(string UserId, string keyword) { List<Domain.Socioboard.Domain.DiscoverySearch> GplusDiscoverySearch = new List<Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { string searchResultObj = GplusDiscoverySearchHelper.GooglePlus(keyword); GooglePlusAccountRepository gplusAccRepo = new GooglePlusAccountRepository(); ArrayList alst = gplusAccRepo.getAllGooglePlusAccounts(); GlobusGooglePlusLib.Authentication.oAuthToken oauth = new GlobusGooglePlusLib.Authentication.oAuthToken(); GooglePlusActivities obj = new GooglePlusActivities(); JObject GplusActivities = JObject.Parse(GplusDiscoverySearchHelper.GooglePlus(keyword)); foreach (JObject gobj in JArray.Parse(GplusActivities["items"].ToString())) { Domain.Socioboard.Domain.DiscoverySearch gpfeed = new Domain.Socioboard.Domain.DiscoverySearch(); gpfeed.Id = Guid.NewGuid(); try { gpfeed.MessageId = gobj["url"].ToString(); gpfeed.CreatedTime = DateTime.Parse(gobj["published"].ToString()); gpfeed.Message = gobj["title"].ToString(); gpfeed.FromId = gobj["actor"]["id"].ToString(); gpfeed.FromName = gobj["actor"]["displayName"].ToString(); gpfeed.ProfileImageUrl = gobj["actor"]["image"]["url"].ToString(); } catch { } GplusDiscoverySearch.Add(gpfeed); } } catch { } return new JavaScriptSerializer().Serialize(GplusDiscoverySearch); }
public string DiscoverySearchFacebook(string UserId, string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { lstDiscoverySearch = dissearchrepo.GetAllSearchKeywordsByUserId(Guid.Parse(UserId), keyword, "facebook"); if (lstDiscoverySearch.Count < 1) { FacebookAccountRepository fbAccRepo = new FacebookAccountRepository(); ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts(); string accesstoken = string.Empty; foreach (Domain.Socioboard.Domain.FacebookAccount item in asltFbAccount) { accesstoken = item.AccessToken; if (this.CheckFacebookToken(accesstoken, keyword)) { break; } } string facebookSearchUrl = "https://graph.facebook.com/v1.0/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100"; 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 { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.CreatedTime = DateTime.Parse(chile["created_time"].ToString()); objDiscoverySearch.EntryDate = DateTime.Now; objDiscoverySearch.FromId = chile["from"]["id"].ToString(); objDiscoverySearch.FromName = chile["from"]["name"].ToString(); objDiscoverySearch.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small"; objDiscoverySearch.SearchKeyword = keyword; objDiscoverySearch.Network = "facebook"; objDiscoverySearch.Message = chile["message"].ToString(); objDiscoverySearch.MessageId = chile["id"].ToString(); objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); string postURL = "https://www.facebook.com/" + objDiscoverySearch.MessageId; 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)); } else { return(new JavaScriptSerializer().Serialize(lstDiscoverySearch)); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please try Again")); } }
public string DiscoverySearchFacebook(string UserId, string keyword) { List <Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List <Domain.Socioboard.Domain.DiscoverySearch>(); string profileid = string.Empty; try { // lstDiscoverySearch = dissearchrepo.GetAllSearchKeywordsByUserId(Guid.Parse(UserId), keyword, "facebook"); FacebookAccountRepository fbAccRepo = new FacebookAccountRepository(); ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts(); string accesstoken = string.Empty; #region Added Sumit Gupta [27/01/15] foreach (Domain.Socioboard.Domain.FacebookAccount item in asltFbAccount) { accesstoken = item.AccessToken; if (this.CheckFacebookToken(accesstoken, keyword)) { break; } } #endregion ////Access Token HARD CODED temporarily //accesstoken = "CAAKMrAl97iIBAD9MqfWtfjIxwFVteGCLVZBsoHpc1TZCH8Kf3KQuMebkbNYLb282cUTisu6iGZBiZAzzwxWvDhh20vCzs5mZCFZBblZBXu40BQisUjoOCZARUQklHBiK3Cx7DOgdXtbvupC4xJ1VpPjKspwiZBRzNYncjgQAyUqd5sGsXUDHcqKy0UBYkmbfq7QZCFgpyG5icOPeMhRb4TXJaic7UF7B1WHLhw2A5EW0kb3AZDZD"; string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100"; 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 { objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch(); objDiscoverySearch.SearchKeyword = keyword; objDiscoverySearch.Network = "facebook"; objDiscoverySearch.Id = Guid.NewGuid(); objDiscoverySearch.UserId = Guid.Parse(UserId); if (!dissearchrepo.isKeywordPresentforNetwork(objDiscoverySearch.SearchKeyword, objDiscoverySearch.Network)) { dissearchrepo.addNewSearchResult(objDiscoverySearch); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { Domain.Socioboard.Domain.DiscoverySearch objSearchHistory = new Domain.Socioboard.Domain.DiscoverySearch(); objSearchHistory.CreatedTime = DateTime.Parse(chile["created_time"].ToString()); objSearchHistory.EntryDate = DateTime.Now; objSearchHistory.FromId = chile["from"]["id"].ToString(); try { objSearchHistory.FromName = chile["from"]["name"].ToString(); } catch { } try { objSearchHistory.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small"; } catch { } objSearchHistory.SearchKeyword = keyword; objSearchHistory.Network = "facebook"; try { objSearchHistory.Message = chile["message"].ToString(); } catch { } try { objSearchHistory.MessageId = chile["id"].ToString(); } catch { } objSearchHistory.Id = Guid.NewGuid(); objSearchHistory.UserId = Guid.Parse(UserId); lstDiscoverySearch.Add(objSearchHistory); } catch { } } } return(new JavaScriptSerializer().Serialize(lstDiscoverySearch)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please try Again")); } }