public void chekLicense()
        {
            #region FreeTrial
            try
            {

                ChilkatHttpHelpr objCjilkatHttpHelper = new ChilkatHttpHelpr();
                string strdateTime_DataBase = ("2016-02-06 23:59:59").ToString();// string strdateTime_DataBase = ("2016-02-04 23:59:59").ToString();

                DateTime dt = DateTime.Parse(strdateTime_DataBase);
                strdateTime_DataBase = dt.ToString("yyyy-MM-dd hh:mm:ss");

                string dateTime = objCjilkatHttpHelper.GetHtml("http://licensing.facedominator.com/licensing/FD/Datetime.php");

                DateTime dt_now = DateTime.Parse(dateTime);

                TimeSpan dt_Difference = dt_now.Subtract(dt);

                if (dt_Difference.Days >= 1)
                {
                    //ModernDialog.ShowMessage("Your Trial Version of Software Has Been Expired!!","Warning Message",MessageBoxButton.OK,this.OwnedWindows);  
                    MessageBox.Show("Your Trial Version of Software Has Been Expired!!");
                    mainFormReference.Close();
                    return;
                }
                

            }
            catch { }
            #endregion
        }
        public static string GetUserIDFromUsername(string username, out string Status)
        {
            string GetStatus = string.Empty;
            Globussoft.GlobusHttpHelper httpHelper = new Globussoft.GlobusHttpHelper();

            clsDBQueryManager DB = new clsDBQueryManager();
            DataSet ds = DB.GetUserId(username);
            string user_id = string.Empty;

            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dataRow in ds.Tables["tb_UsernameDetails"].Rows)
                {
                    user_id = dataRow.ItemArray[0].ToString();
                    Status = "No Error";
                    return user_id;
                }
            }


            try
            {
                string id = string.Empty;

                ChilkatHttpHelpr httpHelper1 = new ChilkatHttpHelpr();
                string pagesource = httpHelper1.GetHtml("https://api.twitter.com/1/users/show.xml?screen_name=" + username);

                if (!pagesource.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour.") && !pagesource.Contains("Sorry, that page does not exist") && !pagesource.Contains("User has been suspended"))
                {
                    int length = pagesource.IndexOf("</id>");
                    id = pagesource.Substring(pagesource.IndexOf("<id>"), length - pagesource.IndexOf("<id>")).Replace("<id>", "");
                    user_id = id;
                    GetStatus = "No Error";
                }
                else if (pagesource.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour."))
                {
                    GetStatus = "Rate limit exceeded";
                }
                else if (pagesource.Contains("Sorry, that page does not exist"))
                {
                    GetStatus = "Sorry, that page does not exist";
                }
                else if (pagesource.Contains("User has been suspended"))
                {
                    GetStatus = "User has been suspended";
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserIDFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserIDFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                GetStatus = "Error";
            }
            Status = GetStatus;
            return user_id;
        }
        public static string GetUserNameFromUserId(string userid)
        {
            string username = string.Empty;

            ChilkatHttpHelpr httpHelper = new ChilkatHttpHelpr();
            clsDBQueryManager DB = new clsDBQueryManager();
            DataSet ds = DB.GetUserName(userid);
            string user_id = string.Empty;

            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dataRow in ds.Tables["tb_UsernameDetails"].Rows)
                {
                    user_id = dataRow.ItemArray[0].ToString();
                    return user_id;
                }
            }
            try
            {
                string PageSource = string.Empty;
                if (!string.IsNullOrEmpty(userid) && NumberHelper.ValidateNumber(userid))
                {
                    PageSource = httpHelper.GetHtml("https://api.twitter.com/1/users/show.xml?user_id=" + userid + "&include_entities=true");
                    if (!PageSource.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour."))
                    {
                        try
                        {
                            int startIndex = PageSource.IndexOf("<screen_name>");
                            if (startIndex > 0)
                            {
                                string Start = PageSource.Substring(startIndex);
                                int endIndex = Start.IndexOf("</screen_name>");
                                string End = Start.Substring(0, endIndex);
                                username = End.Replace("<screen_name>", "");
                            }

                        }
                        catch (Exception ex)
                        {
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }
                    }

                    else
                    {
                        username = "******";
                    }
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }

            return username;
        }
Esempio n. 4
0
        public static List<string> GetAllFriends(ref ChilkatHttpHelpr chilkatHttpHelper, string userId)
        {
            List<string> finalList_Friends = new List<string>();

            List<string> list_finalFriendsID = new List<string>();

            try
            {
                string pgSource_Friends = chilkatHttpHelper.GetHtml("http://www.facebook.com/profile.php?id=" + userId + "&sk=friends");

                string[] Friends = Regex.Split(pgSource_Friends, "user.php");

                ParseFriendIDs(Friends, finalList_Friends);

                List<string> lstnewfriendid = new List<string>();

                // {"collection_token":"1220529617:2356318349:2","cursor":"MDpub3Rfc3RydWN0dXJlZDoxMDAwMDA5MjM1MTg5MjY=","tab_key":"friends","profile_id":1220529617,"overview":false,"ftid":null,"order":null,"sk":"friends"}


                string collection_token = "";
                string cursor = "";

                //check if all friends loaded
                string patternAllFriendsLoaded = "\"TimelineAppCollection\",\"setFullyLoaded\",[],[\"pagelet_timeline_app_collection_";

                int tempCount_AjaxRequests = 0;

                do //
                {
                    try
                    {
                        collection_token = "";
                        cursor = "";

                        string[] arry = Regex.Split(pgSource_Friends, "enableContentLoader");
                        if (arry.Length > 1)
                        {
                            try
                            {
                                string rawData = arry[1];

                                int startIndx_collection_token = rawData.IndexOf("pagelet_timeline_app_collection_") + "pagelet_timeline_app_collection_".Length;
                                int endIndx_collection_token = rawData.IndexOf("\"", startIndx_collection_token);
                                collection_token = rawData.Substring(startIndx_collection_token, endIndx_collection_token - startIndx_collection_token);

                                int startIndx_cursor = rawData.IndexOf(",\"", endIndx_collection_token) + ",\"".Length;
                                int endIndx_cursor = rawData.IndexOf("\"", startIndx_cursor);
                                cursor = rawData.Substring(startIndx_cursor, endIndx_cursor - startIndx_cursor);
                            }
                            catch (Exception ex)
                            {
                                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                            }

                        }

                        string raw_data = "{\"collection_token\":\"" + collection_token + "\",\"cursor\":\"" + cursor + "\",\"tab_key\":\"friends\",\"profile_id\":" + userId + ",\"overview\":false,\"ftid\":null,\"order\":null,\"sk\":\"friends\"}";
                        string encoded_raw_data = Uri.EscapeDataString(raw_data);

                        string getURL_MoreFriendsAjax = "https://www.facebook.com/ajax/pagelet/generic.php/AllFriendsAppCollectionPagelet?data=" + encoded_raw_data + "&__user="******"&__a=1&__dyn=7n8ahyj2qmudwNAEU&__req=2";
                        string res_getURL_MoreFriendsAjax = chilkatHttpHelper.GetHtml(getURL_MoreFriendsAjax);

                        pgSource_Friends = res_getURL_MoreFriendsAjax;

                        string[] arry_UserData = Regex.Split(pgSource_Friends, "user.php");

                        ParseFriendIDs(arry_UserData, finalList_Friends);

                        tempCount_AjaxRequests++;
                    
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                    }

                } while ((collection_token != "" && cursor != "") || tempCount_AjaxRequests < 15 || pgSource_Friends.Contains(patternAllFriendsLoaded));



                finalList_Friends.ForEach(delegate(String friendID)
                {
                    if (friendID.Contains("&"))
                    {
                        friendID = friendID.Remove(friendID.IndexOf("&"));
                    }
                    list_finalFriendsID.Add(friendID);
                });

                list_finalFriendsID = list_finalFriendsID.Distinct().ToList();
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }

            return list_finalFriendsID;
        }
        /// <summary> Get User details for While/blacklist User 
        /// Get User details for While/blacklist User 
        /// </summary>
        /// <param name="username">User Screan Name OR User ID</param>
        /// <returns>Details of Users</returns>

        #region Get User details for While/blacklist User
        public static Dictionary<string, string> GetUserDetails(string username)
        {
            ChilkatHttpHelpr httpHelper = new ChilkatHttpHelpr();

            Dictionary<string, string> dataLst = new Dictionary<string, string>();

            try
            {
                string PageSource = null;

                if (!string.IsNullOrEmpty(username) && NumberHelper.ValidateNumber(username))
                {
                    PageSource = httpHelper.GetHtml("https://api.twitter.com/1/users/show.json?user_id=" + username + "&include_entities=true");
                }
                else
                {
                    PageSource = httpHelper.GetHtml("https://api.twitter.com/1/users/show.json?screen_name=" + username + "&include_entities=true");
                }

                JObject jobj = JObject.Parse(PageSource);


                string id = jobj["id"].ToString().Replace("\"", string.Empty);
                dataLst.Add("id", id);
                string name = jobj["name"].ToString().Replace("\"", string.Empty);
                dataLst.Add("name", name);
                string screen_name = jobj["screen_name"].ToString().Replace("\"", string.Empty);
                dataLst.Add("screen_name", screen_name);
                string location = jobj["location"].ToString().Replace("\"", string.Empty);
                dataLst.Add("location", location);
                string description = jobj["description"].ToString().Replace("\"", string.Empty);
                dataLst.Add("description", description);
                string followers_count = jobj["followers_count"].ToString().Replace("\"", string.Empty);
                dataLst.Add("followers_count", followers_count);
                string friends_count = jobj["friends_count"].ToString().Replace("\"", string.Empty);
                dataLst.Add("friends_count", friends_count);
                string statuses_count = jobj["statuses_count"].ToString().Replace("\"", string.Empty);
                dataLst.Add("statuses_count", statuses_count);
                string created_at = jobj["created_at"].ToString().Replace("\"", string.Empty);
                dataLst.Add("created_at", created_at);
                string time_zone = jobj["time_zone"].ToString().Replace("\"", string.Empty);
                dataLst.Add("time_zone", time_zone);
                string profile_image_url = jobj["profile_image_url"].ToString().Replace("\"", string.Empty);
                dataLst.Add("profile_image_url", profile_image_url);
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }

            return dataLst;
        }
        public List<string> GetHashTags(out string returnStatus)
        {
            List<string> HashTags = new List<string>();
            try
            {
                //string pagesource = globushttpHelper.getHtmlfromUrl(new Uri("https://api.twitter.com/1/trends/daily.json"), "", "");
                ChilkatHttpHelpr HttpHelper = new ChilkatHttpHelpr();
                string pagesource = HttpHelper.GetHtml("https://api.twitter.com/1/trends/daily.json");

                if (!pagesource.Contains("Rate limit exceeded"))
                {
                    string[] array = Regex.Split(pagesource, "\"name\":");
                    array = array.Skip(1).ToArray();
                    foreach (string item in array)
                    {
                        try
                        {
                            int startindex = item.IndexOf("\"");
                            string Start = item.Substring(startindex);
                            int endIndex = Start.IndexOf("\",");
                            string End = Start.Substring(0, endIndex).Replace("\"", "");

                            string HashTag = End;

                            if (HashTag.Contains("#"))
                            {
                                HashTags.Add(HashTag);
                            }
                        }
                        catch (Exception ex)
                        {
                            returnStatus = "Error";
                            return new List<string>();
                        }
                    }
                    returnStatus = "No Error";
                    return HashTags;
                }
                else
                {
                    returnStatus = "Error";
                    return new List<string>();
                }
            }
            catch (Exception ex)
            {
                returnStatus = "Error";
                return new List<string>();
            }
        }
        public List<string> GetFollowings(string userID, out string ReturnStatus)
        {
            try
            {
                string FollowingUrl = string.Empty;
                if (NumberHelper.ValidateNumber(userID))
                {
                    FollowingUrl = "https://api.twitter.com/1/following/ids.json?cursor=-1&id=" + userID + "";//"https://api.twitter.com/1/following/ids.json?cursor=-1&screen_name=SocioPro";
                }
                else
                {
                    FollowingUrl = "https://api.twitter.com/1/following/ids.json?cursor=-1&screen_name=" + userID + "";//"https://api.twitter.com/1/following/ids.json?cursor=-1&screen_name=SocioPro";
                }

                ChilkatHttpHelpr HttpHelper = new ChilkatHttpHelpr();
                string Data = HttpHelper.GetHtml(FollowingUrl);//.getHtmlfromUrl(new Uri(FollowingUrl), "", "");

                if (!Data.Contains("Rate limit exceeded"))
                {
                    int FirstPoint = Data.IndexOf("[");
                    int SecondPoint = Data.IndexOf("]");

                    string FollowingIds = Data.Substring(FirstPoint, SecondPoint - FirstPoint).Replace("[", string.Empty).Replace("]", string.Empty);

                    List<string> lstIds = FollowingIds.Split(',').ToList();

                    ReturnStatus = "No Error";
                    return lstIds;
                }
                else
                {
                    ReturnStatus = "Error";
                    return new List<string>();
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetFollowings() -- " + userID + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetFollowings() -- " + userID + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                ReturnStatus = "Error";
                return new List<string>();
            }
        }
        public string GetUserLastTweetDate(string userid)
        {
            string date = "";

            try
            {
                string user_id = string.Empty;

                string searchURL = string.Empty;

                if (!NumberHelper.ValidateNumber(userid))
                {
                    searchURL = "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&id=" + user_id + "&count=" + TweetExtractCount;
                }
                else if (NumberHelper.ValidateNumber(userid))
                {
                    searchURL = "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=" + user_id + "&count=" + TweetExtractCount;
                }

                //string searchURL = "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&id=" + user_id + "&count=" + TweetExtractCount;
                ChilkatHttpHelpr httpHelper = new ChilkatHttpHelpr();
                //string res_Get_searchURL = globushttpHelper.getHtmlfromUrl(new Uri(searchURL), "", "");
                string res_Get_searchURL = httpHelper.GetHtml(searchURL);

                string[] splitRes = Regex.Split(res_Get_searchURL, "{\"created_at");//Regex.Split(res_Get_searchURL, "{\"created_at\"");
                splitRes = splitRes.Skip(1).ToArray();

                foreach (string item in splitRes)
                {
                    //string text = Globussoft.GlobusHttpHelper.ParseJson(modified_Item, "<text>");
                    string modified_Item = "{\"created_at" + item;

                    date = Globussoft.GlobusHttpHelper.ParseJson(modified_Item, "created_at");//Globussoft.GlobusHttpHelper.parseText(item);
                    if (date.Contains("+"))
                    {
                        date = date.Remove(date.IndexOf("+")).Trim();
                    }
                    if (!string.IsNullOrEmpty(date))
                    {
                        return date;
                    }
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserLastTweetDate() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserLastTweetDate() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }

            return date;
        }
        public List<string> GetRetweetData_Scrape(string keyword, out string returnStatus)
        {
            string status = string.Empty;
            List<string> lst_ReTweetIDs = new List<string>();
            try
            {
                string searchURL = string.Empty;

                if (!NumberHelper.ValidateNumber(keyword))
                {
                    searchURL = "https://api.twitter.com/1/statuses/retweeted_by_user.xml?screen_name=" + keyword + "&count=" + RetweetExtractcount + "&include_entities=true";
                }
                else if (NumberHelper.ValidateNumber(keyword))
                {
                    searchURL = "https://api.twitter.com/1/statuses/retweeted_by_user.xml?id=" + keyword + "&count=" + RetweetExtractcount + "&include_entities=true";
                }

                //string res_Get_searchURL = globushttpHelper.getHtmlfromUrl(new Uri(searchURL), "", "");
                ChilkatHttpHelpr HttpHelper = new ChilkatHttpHelpr();
                string res_Get_searchURL = HttpHelper.GetHtml(searchURL);

                if (!res_Get_searchURL.Contains("Rate limit exceeded") && !res_Get_searchURL.Contains("Sorry, that page does not exist") && res_Get_searchURL.Contains("created_at") && !string.IsNullOrEmpty(res_Get_searchURL))
                {
                    string[] splitRes = Regex.Split(res_Get_searchURL, "<status>");//Regex.Split(res_Get_searchURL, "{\"created_at\"");
                    splitRes = splitRes.Skip(1).ToArray();

                    foreach (string item in splitRes)
                    {
                        string Tweet = string.Empty;
                        string Tweeter = string.Empty;
                        try
                        {
                            int startIndex = item.IndexOf("<text>");
                            string start = item.Substring(startIndex);
                            int endIndex = start.IndexOf("</text>");
                            string end = start.Substring(0, endIndex);
                            Tweet = end.Replace("<text>", "");

                            int startOfInndex = Tweet.IndexOf(":");
                            Tweeter = Tweet.Substring(0, startOfInndex);
                            Tweet = Tweet.Replace(Tweeter, "");
                        }
                        catch (Exception ex)
                        {
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetRetweetData_Scrape() -- " + keyword + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetRetweetData_Scrape() -- " + keyword + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }

                        string data = keyword + ":" + Tweeter + ":" + Tweet.Replace(":", "^");
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(data, Globals.Path_RETweetExtractor);
                        lst_ReTweetIDs.Add(data);
                    }
                }
                else if (res_Get_searchURL.Contains("Rate limit exceeded"))
                {
                    status = "Rate limit exceeded";
                }
                else if (res_Get_searchURL.Contains("Sorry, that page does not exist"))
                {
                    status = "Sorry, that page does not exist";
                }
                else if (res_Get_searchURL.Contains("Not authorized"))
                {
                    status = "Not Authorized";
                }
                else if (string.IsNullOrEmpty(res_Get_searchURL))
                {
                    status = "Not Authorized";
                }
                else
                {
                    status = "Empty";
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetRetweetData_Scrape() -- " + keyword + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetRetweetData_Scrape() -- " + keyword + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                status = "Error";
            }
            returnStatus = status;
            return lst_ReTweetIDs;
        }
        public List<string> GetTweetData_Scrape(string keyword, out string returnStatus)
        {
            string status = string.Empty;
            List<string> lst_TweetIDs = new List<string>();
            try
            {
                string user_id = string.Empty;

                #region old code
                //if (!NumberHelper.ValidateNumber(keyword))
                //{
                //    user_id = GetUserIDFromUsername(keyword);
                //}
                //else
                //{
                //    user_id = keyword;
                //}

                //if (!string.IsNullOrEmpty(user_id))
                //{
                //screen_name  
                #endregion

                string searchURL = string.Empty;
                if (NumberHelper.ValidateNumber(keyword))
                {
                    searchURL = "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&id=" + keyword + "&count=" + TweetExtractCount;
                }
                else
                {
                    searchURL = "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=" + keyword + "&count=" + TweetExtractCount;
                }
                //string res_Get_searchURL = globushttpHelper.getHtmlfromUrl(new Uri(searchURL), "", "");
                ChilkatHttpHelpr HttpHelper = new ChilkatHttpHelpr();
                string res_Get_searchURL = HttpHelper.GetHtml(searchURL);

                if (!res_Get_searchURL.Contains("Rate limit exceeded") && !res_Get_searchURL.Contains("Sorry, that page does not exist") && !res_Get_searchURL.Contains("Not authorized") && res_Get_searchURL.Contains("created_at") && !string.IsNullOrEmpty(res_Get_searchURL))
                {
                    string[] splitRes = Regex.Split(res_Get_searchURL, "{\"created_at");//Regex.Split(res_Get_searchURL, "{\"created_at\"");
                    splitRes = splitRes.Skip(1).ToArray();

                    foreach (string item in splitRes)
                    {
                        //string text = Globussoft.GlobusHttpHelper.ParseJson(modified_Item, "<text>");
                        string Tweet = Globussoft.GlobusHttpHelper.ParseJson(item, "text");//Globussoft.GlobusHttpHelper.parseText(item);
                        string data = keyword + ":" + Tweet;
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(data, Globals.Path_TweetExtractor);
                        lst_TweetIDs.Add(data);
                    }
                    status = "No Error";
                }
                else if (res_Get_searchURL.Contains("Rate limit exceeded"))
                {
                    status = "Rate limit exceeded";
                }
                else if (res_Get_searchURL.Contains("Sorry, that page does not exist"))
                {
                    status = "Sorry, that page does not exist";
                }
                else if (res_Get_searchURL.Contains("Not authorized"))
                {
                    status = "Not Authorized";
                }
                else if (string.IsNullOrEmpty(res_Get_searchURL))
                {
                    status = "Not Authorized";
                }
                else
                {
                    status = "Empty";
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetTweetData_Scrape() -- " + keyword + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetTweetData_Scrape() -- " + keyword + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                status = "Error";
            }
            returnStatus = status;
            return lst_TweetIDs;
        }
        public static string GetPhotoFromUsername(string username)
        {
            //Globussoft.GlobusHttpHelper httpHelper = new Globussoft.GlobusHttpHelper();
            ChilkatHttpHelpr httpHelper = new ChilkatHttpHelpr();

            string user_id = string.Empty;
            string containsImage = "false";
            try
            {
                string ImageLink = string.Empty;
                string PageSource = string.Empty;
                //http://a0.twimg.com/sticky/default_profile_images/default_profile_0_normal.png
                if (!string.IsNullOrEmpty(username) && NumberHelper.ValidateNumber(username))
                {
                    //PageSource = httpHelper.getHtmlfromUrl(new Uri("https://api.twitter.com/1/users/show.xml?user_id=" + username + "&include_entities=true"), "", "");
                    PageSource = httpHelper.GetHtml("https://api.twitter.com/1/users/show.xml?user_id=" + username + "&include_entities=true");
                }
                else
                {
                    //PageSource = httpHelper.getHtmlfromUrl(new Uri("https://api.twitter.com/1/users/show.xml?screen_name=" + username + "&include_entities=true"), "", "");
                    PageSource = httpHelper.GetHtml("https://api.twitter.com/1/users/show.xml?screen_name=" + username + "&include_entities=true");
                }

                if (!string.IsNullOrEmpty(PageSource))
                {
                    try
                    {
                        int indexStart = PageSource.IndexOf("<profile_image_url>");
                        if (PageSource.Contains("<profile_image_url>"))
                        {
                            string start = PageSource.Substring(indexStart);
                            int endIndex = start.IndexOf("</profile_image_url>");
                            string end = start.Substring(0, endIndex);
                            ImageLink = end.Replace("<profile_image_url>", "");
                        }

                        if (!string.IsNullOrEmpty(ImageLink) && ImageLink.Contains("/sticky/default_profile_images/default_profile"))
                        {
                            containsImage = "false";
                        }
                        else if (PageSource.Contains("Sorry, that page does not exist"))
                        {
                            containsImage = "false";
                        }
                        else
                        {
                            containsImage = "true";
                        }
                    }
                    catch (Exception ex)
                    {
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                    }
                }
                else if (PageSource.Contains("Clients may not make more than 150 requests per hour") && PageSource.Contains("Rate limit exceeded"))
                {
                    containsImage = "Rate limit exceeded";
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }

            return containsImage;
        }
        /// <summary>
        /// Checks the status of the CPUID from Database
        /// If status is Active, MainFrm starts
        /// </summary>
        public bool ValidateCPUID(ref string statusMessage, string servr, ref string username,ref string Password , ref string txnID, string freeTrialKey, string cpuID,ref string Email)
        {
            //string cpuID = getCPUID();
            try
            {
              
                #region Drct
                //string cpuID = FetchMacId();
                //string SelectQuery = "Select * from users where cpuid='" + cpuID + "'";
                //DataSet ds = DataBaseHandler.SelectQuery(SelectQuery, "users");
                //if (ds.Tables[0].Rows.Count == 1)
                //{
                //    string status = ds.Tables[0].Rows[0]["status"].ToString();
                //    if (status.ToLower() == "active")
                //    {
                //        statusMessage = "active";
                //        return true;
                //    }
                //    else if (status.ToLower() == "nonactive")
                //    {
                //        statusMessage = "nonactive";
                //        return false;
                //    }
                //    else if (status.ToLower() == "suspended")
                //    {
                //        statusMessage = "suspended";
                //        return false;
                //    }
                //}

                #endregion

                #region Through php

               
                //string cpuID = FetchMacId();
                //ChilkatHttpHelpr HttpHelpr = new ChilkatHttpHelpr();
                HttpHelpr = new ChilkatHttpHelpr();

                #region Servr 1
                {
                    string res = string.Empty;
                    res = HttpHelpr.GetHtml("http://" + servr + "/GetUserData.php?cpid=" + cpuID + "");
                   
                    if (string.IsNullOrEmpty(res))
                    {
                        System.Threading.Thread.Sleep(1000);
                        res = HttpHelpr.GetHtml("http://" + servr + "/releases/GetUserData.php?cpid=" + cpuID + "");
                    }



                    if (!string.IsNullOrEmpty(res))
                    {
                        string activationstatus = string.Empty;
                        string dateTime = string.Empty;
                  
                        string trimmed_response = res.Replace("<pre>", "").Replace("</pre>", "").Trim().ToLower();

                        string[] array_status = System.Text.RegularExpressions.Regex.Split(trimmed_response, "<:>");
                        try
                        {
                            activationstatus = array_status[0].ToLower();
                        }
                        catch { }
                        try
                        {
                            dateTime = array_status[1].ToLower();
                        }
                        catch { }
                        try
                        {
                            username = array_status[2].ToLower();
                        }
                        catch { }
                        try
                        {
                            Password = array_status[3].ToLower();
                        }
                        catch { };

                        try
                        {
                            txnID = array_status[4].ToLower();
                        }
                        catch { }
                        try
                        {
                            Email = array_status[5].ToLower();
                        }
                        catch { };

                        try
                        {
                            if (txnID.Contains("freetrial"))
                            {
                                Globals.Licence_Details = username + ":" + dateTime + "&" + "FreeTrial" + "";
                            }
                            else
                            {
                                Globals.Licence_Details = username + ":" + dateTime + "&" + "Full Version" + "";
                            }
                        }
                        catch { }

                        if (trimmed_response.ToLower().Contains(freeTrialKey) && ((activationstatus.ToLower() == "active") || (activationstatus.ToLower() == "nonactive")))
                        {
                            
                        

                            if (CheckActivationUpdateStatus(cpuID, dateTime, activationstatus, servr))
                            {
                                statusMessage = "active";
                                return true;
                            }
                            else
                            {
                                statusMessage = "trialexpired";
                                return false;
                            }

                            if (activationstatus.ToLower() == "active")
                            {
                                statusMessage = "active";
                                return true;
                            }
                            else//else if (activationstatus.ToLower() == "nonactive")
                            {
                                //Update status as Active
                                string updateRes = HttpHelpr.GetHtml("http://" + servr + "/UpdateStatus.php?cpid=" + cpuID + "&status=" + "Active");
                                if (string.IsNullOrEmpty(updateRes))
                                {
                                    System.Threading.Thread.Sleep(1000);
                                    updateRes = HttpHelpr.GetHtml("http://" + servr + "/UpdateStatus.php?cpid=" + cpuID + "&status=" + "Active");
                                }
                                MessageBox.Show("Your Free Version is Activated");
                                return true;
                            }

                     
                            

                           
                        }
                        else if (activationstatus.ToLower() == "active")
                        {
                            statusMessage = "active";
                          
                            return true;
                            // DisableControls();
                        }
                        else if (activationstatus.ToLower() == "nonactive")
                        {
                            statusMessage = "nonactive";
                          
                            MessageBox.Show("Verification of your txn is under process.\n Please wait for your Transaction to be verified.\n Please Contact To Support Team to activate your license,   Skype Id Is :- Facedominatorsupport");
                            return false;
                            //DisableControls();
                        }
                        else if (trimmed_response.Contains("trialexpired"))
                        {
                            statusMessage = "trialexpired";
                            MessageBox.Show("Your 3 Days Trial Version has Expired. Please visit our site: facedominator.com to purchase your License");
                            return false;
                        }
                        else if (trimmed_response.ToLower() == "suspended")
                        {
                            statusMessage = "suspended";
                            return false;
                        }
                        else if (trimmed_response.Contains("no record found"))
                        {
                            statusMessage = "norecordfound";
                            return false;
                        }
                        else
                        {
                            statusMessage = "Some Error in Licensing Server";
                            return false;
                        }

                    }
                    else
                    {
                        statusMessage = "ServerDown";
                        return false;
                    }
                }
                #endregion
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                statusMessage = "Error in License Validation";
                MessageBox.Show(ex.StackTrace);
            }
            return false;
        }
        public string RegisterUser(string Username, string Password, string cpuID, string TransactionID, string Email, string servr)
        {
            ChilkatHttpHelpr HttpHelpr = new ChilkatHttpHelpr();
            string res = string.Empty;
            try
            {
                string regUrl = "http://" + servr + "/register.php?user="******"&pass="******"&cpid=" + cpuID + "&transid=" + TransactionID + "&email=" + Email + "";
                res = HttpHelpr.GetHtml("http://" + servr + "/register.php?user="******"&pass="******"&cpid=" + cpuID + "&transid=" + TransactionID + "&email=" + Email + "");

                if (string.IsNullOrEmpty(res))
                {
                    System.Threading.Thread.Sleep(1000);
                    res = HttpHelpr.GetHtml("http://" + servr + "/register.php?user="******"&pass="******"&cpid=" + cpuID + "&transid=" + TransactionID + "&email=" + Email + "");
                }

                if (string.IsNullOrEmpty(res))
                {
                    MessageBox.Show("Error Connecting to Facedominator Server,Please check if www.facedominator.com is opening for you.");
                   // Application.Exit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return res;
        }
        public static string GetUserNameFromUserId(string userid)
        {
            string username = string.Empty;

            ChilkatHttpHelpr httpHelper = new ChilkatHttpHelpr();

            try
            {
                string PageSource = string.Empty;
                if (!string.IsNullOrEmpty(userid) && NumberHelper.ValidateNumber(userid))
                {
                    //PageSource = httpHelper.GetHtml("https://api.twitter.com/1/users/show.xml?user_id=" + userid + "&include_entities=true");
                    PageSource = httpHelper.GetHtml(("https://twitter.com/account/redirect_by_id?id=" + userid));
                    if (!PageSource.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour."))
                    {
                        try
                        {
                            //int startIndex = PageSource.IndexOf("<screen_name>");
                            //if (startIndex > 0)
                            {
                                //string Start = PageSource.Substring(startIndex);
                                //int endIndex = Start.IndexOf("</screen_name>");
                                //string End = Start.Substring(0, endIndex);
                                //username = End.Replace("<screen_name>", "");

                                int startindex = PageSource.IndexOf("user-style-");
                                string start = PageSource.Substring(startindex).Replace("user-style-", "");
                                int endindex = start.IndexOf("\"");
                                string end = start.Substring(0, endindex);
                                username = end;
                            }

                        }
                        catch (Exception ex)
                        {
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }
                    }
                    else
                    {
                        username = "******";
                    }
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }

            return username;
        }
Esempio n. 15
0
         //----------------Check Facebook Accounts------------------//     

        public void CheckFacebookAccounts(ref FacebookUser fbUser)
        {
            GlobusLogHelper.log.Info("Start Process Check Facebook Account : " + fbUser.username);
            GlobusLogHelper.log.Debug("Start Process Check Facebook Account : " + fbUser.username);
            try
            {

                if (string.IsNullOrEmpty(exportFilePathAccountVerification))
                {
                    string path = Utils.UploadFolderData(GlobusFileHelper.DesktopPath);
                    exportFilePathAccountVerification = path;
                }
                string EmailId = fbUser.username;
                string password = fbUser.password;
                string proxyAddress = fbUser.proxyip;
                string proxyPort = fbUser.proxyport;
                string proxyUserName = fbUser.proxyusername;
                string proxyPassword = fbUser.proxypassword;

                if (string.IsNullOrEmpty(proxyPort) && !Utils.IsNumeric(proxyPort))
                {
                    proxyPort = "80";
                }
                string strPageSource = string.Empty;
                string fb_dtsg = "";
                string str_lsd = "";
                ChilkatHttpHelpr HttpHelpr = new ChilkatHttpHelpr();
                try
                {
                    if (!string.IsNullOrEmpty(proxyAddress))
                    {
                        strPageSource = HttpHelpr.GetHtmlProxy(FBGlobals.Instance.AccountVerificationCheckFacebookAccountsidentifyPhpUrl, proxyAddress, (proxyPort), proxyUserName, proxyPassword);   //"http://www.facebook.com/help/identify.php?ctx=recover"
                    }
                    else
                    {
                        strPageSource = HttpHelpr.GetHtml(FBGlobals.Instance.AccountVerificationCheckFacebookAccountsidentifyPhpUrl);
                    }
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(ex.StackTrace);
                }
                fb_dtsg = GlobusHttpHelper.Get_fb_dtsg(strPageSource);
                string emailEncode = EmailId.Replace("@", "%40");
                try
                {
                    str_lsd = strPageSource.Substring(strPageSource.IndexOf("name=\"lsd\" value=\""), (strPageSource.IndexOf("autocomplete", strPageSource.IndexOf("name=\"lsd\" value=\"")) - strPageSource.IndexOf("name=\"lsd\" value=\""))).Replace("name=\"lsd\" value=\"", string.Empty).Trim().Replace("\"", string.Empty);
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(ex.StackTrace);
                }
                string FbstatusPostData = "lsd=" + str_lsd + "&email=" + EmailId + "&did_submit=Search&__user=0&__a=1&__dyn=7w86A&__req=2&fb_dtsg=" + fb_dtsg + "&phstamp=165816872817579102116";
                string FBstatusResponse = HttpHelpr.PostData(FBGlobals.Instance.AccountVerificationCheckFacebookAccountsAjaxLoginHelpUrl, FbstatusPostData, FBGlobals.Instance.AccountVerificationCheckFacebookAccountsLoginIdentifyUrl);        //"https://www.facebook.com/ajax/login/help/identify.php?ctx=recover"//"https://www.facebook.com/login/identify?ctx=recover"
                string strPageSource1 = HttpHelpr.GetHtml(FBGlobals.Instance.AccountVerificationCheckRecoverInitiateUrl);       

                Accounts.AccountManager objAccountManager = new AccountManager();
                objAccountManager.LoginUsingGlobusHttp(ref fbUser);

                if (!fbUser.isloggedin)
                {
                    if (strPageSource1.Contains("fsm fwn fcg") && !strPageSource1.Contains("Find Your Account"))
                    {
                        if (strPageSource1.Contains("Reset Your Password"))
                        {
                            GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\ResetYourPassword.txt");
                            GlobusLogHelper.log.Debug("Email : " + EmailId + "Required Security check");
                            GlobusLogHelper.log.Info("Email : " + EmailId + "Required Security check");
                        }
                        else
                        {
                            if (strPageSource1.Contains("Account Disabled") && strPageSource1.Contains("Your account has been disabled"))
                            {
                                GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\AccountDisabledOnFacebook.txt");
                                GlobusLogHelper.log.Debug("Email : " + EmailId + "Your account has been disabled.");
                                GlobusLogHelper.log.Info("Email : " + EmailId + " Your account has been disabled.");
                            }
                            else
                            {
                                GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\HaveAnAccountOnFacebook.txt");
                                GlobusLogHelper.log.Debug("Email : " + EmailId + " Have An Account on Facebook");
                                GlobusLogHelper.log.Info("Email : " + EmailId + " Have An Account on Facebook");
                            }
                        }
                    }
                    else
                    {
                        if (strPageSource1.Contains("A security check is required to proceed"))
                        {
                            GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\SecurityCheckIsRequired.txt");
                            GlobusLogHelper.log.Debug("Email : " + EmailId + "Required Security check");
                            GlobusLogHelper.log.Info("Email : " + EmailId + "Required Security check");
                        }
                        else if (strPageSource1.Contains("Incorrect Email"))
                        {
                            GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\IncorrectEmail.txt");
                            GlobusLogHelper.log.Debug("Email : " + EmailId + "Required Security check");
                            GlobusLogHelper.log.Info("Email : " + EmailId + "Required Security check");
                        }

                        else
                        {
                            GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\NotHaveAccountOnFacebook.txt");
                            GlobusLogHelper.log.Debug("Email : " + EmailId + "Not Have Account on Facebook");
                            GlobusLogHelper.log.Info("Email : " + EmailId + "Not Have Account on Facebook");
                        }
                    }
                }
                else
                {
                    if (fbUser.isloggedin)
                    {
                        GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\WorkingFacebookAccount.txt");
                        GlobusLogHelper.log.Debug("Email : " + EmailId + " Have An Account on Facebook");
                        GlobusLogHelper.log.Info("Email : " + EmailId + " Have An Account on Facebook");
                    }
                    else
                    {
                        GlobusFileHelper.AppendStringToTextfileNewLine(fbUser.username + ":" + fbUser.password + ":" + fbUser.proxyip + ":" + fbUser.proxyport + ":" + fbUser.proxyusername + ":" + fbUser.proxypassword, exportFilePathAccountVerification + "\\HaveAnAccountOnFacebook.txt");
                        GlobusLogHelper.log.Debug("Email : " + EmailId + " Have An Account on Facebook");
                        GlobusLogHelper.log.Info("Email : " + EmailId + " Have An Account on Facebook");
                    }


                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(ex.StackTrace);
            }
        }