Пример #1
0
        public void ReTweetAndFollow(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetID, string tweetMessage, string UserID, out string status)
        {
            Follower.Follower objFollower = new Follower.Follower();
            try
            {
                string TweetId        = tweetID;// "197682704844734464";
                string ReTweetData    = "authenticity_token=" + postAuthenticityToken + "&id=" + tweetID;
                string ReTweetPostUrl = "https://twitter.com/i/tweet/retweet";

                string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://twitter.com/", postAuthenticityToken, "XMLHttpRequest", "true", "");

                string pagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com"), "", "");
                //string TweetId = tweetID;// "197682704844734464";
                //string ReTweetData = "post_authenticity_token=" + postAuthenticityToken;
                //string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json";
                //string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", "");

                status = "posted";

                objFollower.FollowUsingProfileID_New(ref globusHttpHelper, pgSrc, postAuthenticityToken, UserID, out status);
            }
            catch (Exception ex)
            {
                status = "not posted";
                //Log("Method>>ReTweet  --- class>>Tweeter.cs : ReTweet Exception " + ex.Message);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TweetingErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
Пример #2
0
        public bool LogoutHttpHelper(ref Globussoft.GlobusHttpHelper HttpHelper)
        {
            try
            {
                string pageSource1 = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/"));

                if (pageSource1.Contains("\"h\"") && pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg"))
                {
                    string h            = string.Empty;
                    string post_form_id = string.Empty;
                    string fb_dtsg      = string.Empty;

                    if (pageSource1.Contains("\"h\""))
                    {
                        string   strTemp = pageSource1.Substring(pageSource1.IndexOf("\"h\""), 200);
                        string[] ArrTemp = strTemp.Split('"');
                        h = ArrTemp[3];
                    }
                    if (pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg"))
                    {
                        string   strTemp = pageSource1.Substring(pageSource1.IndexOf("post_form_id"), 200);
                        string[] ArrTemp = strTemp.Split('"');
                        post_form_id = ArrTemp[2];
                        fb_dtsg      = ArrTemp[6];
                    }

                    string ResponseLogout = HttpHelper.postFormData(new Uri("http://www.facebook.com/logout.php"), "post_form_id=" + post_form_id + "&fb_dtsg=" + fb_dtsg + "&ref=mb&h=" + h);

                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(false);

                Console.WriteLine(ex.Message);
            }
        }
Пример #3
0
        public bool UpdateProfile(string profileUsername, string profileLocation, string profileFirstName, string profileLastName, string profilePic, string profileAbout, string profileGender, ref Globussoft.GlobusHttpHelper globusHttpHelper, string appversion)
        {
            string Email           = string.Empty;
            string language        = string.Empty;
            string Username        = string.Empty;
            string gender          = string.Empty;
            string firstname       = string.Empty;
            string lastname        = string.Empty;
            string about           = string.Empty;
            string location        = string.Empty;
            string website         = string.Empty;
            string CsrfMiddleToken = string.Empty;
            string userid          = string.Empty;
            string Country         = string.Empty;
            //string appversion = string.Empty;
            string res_ProfilePage = globusHttpHelper.getHtmlfromUrl(new Uri("https://pinterest.com/settings/"), "https://pinterest.com/", "", "");

            // string Res_settingPagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/resource/UserSettingsResource/get/?source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%7D%2C%22context%22%3A%7B%22app_version%22%3A%22da919e8%22%2C%22https_exp%22%3Afalse%7D%2C%22module%22%3A%7B%22name%22%3A%22UserEdit%22%2C%22options%22%3A%7B%22user_id%22%3A%2297460916844499785%22%7D%7D%2C%22append%22%3Afalse%2C%22error_strategy%22%3A0%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)&_=1388747100460"), "", "");
            Email = getEmail(res_ProfilePage);

            userid = getUserid(res_ProfilePage);
            string Res_settingPagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/resource/UserSettingsResource/get/?source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%7D%2C%22context%22%3A%7B%22app_version%22%3A%22" + appversion + "%22%2C%22https_exp%22%3Afalse%7D%2C%22module%22%3A%7B%22name%22%3A%22UserEdit%22%2C%22options%22%3A%7B%22user_id%22%3A%22" + userid + "%22%7D%7D%2C%22append%22%3Afalse%2C%22error_strategy%22%3A0%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)&_=1388747100460"), "", "", "");


            CsrfMiddleToken = getCsrfToken(res_ProfilePage);

            if (string.IsNullOrEmpty(profileFirstName))
            {
                firstname = getFirstName(Res_settingPagesource);
            }
            else
            {
                firstname = profileFirstName;
            }

            if (string.IsNullOrEmpty(profileLastName))
            {
                //lastname = getLastName(res_ProfilePage);
                lastname = getLastName(Res_settingPagesource);
            }
            else
            {
                lastname = profileLastName;
            }

            if (string.IsNullOrEmpty(profileUsername))
            {
                //Username = getUsername(res_ProfilePage);
                Username = getUsername(Res_settingPagesource);
            }
            else
            {
                Username = profileUsername;
                // CheckUsername:
                //string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/check_username/?check_username="******"&csrfmiddlewaretoken=" + CsrfMiddleToken), "https://pinterest.com/settings/", "", "");
                //if (pageSource.Contains("The username is already in use") || pageSource.Contains("failure"))
                //{
                //    Username = RandomStringGenerator.RemoveChars(Username);
                //    if (Username.Count() > 10)
                //    {
                //        Username = Username.Remove(5); //Removes the extra characters
                //    }
                //    string addChars = RandomStringGenerator.RandomNumber(5);
                //    Username = Username + addChars;

                //    if (Username.Count() > 15)
                //    {
                //        Username = Username.Remove(13); //Removes the extra characters
                //    }

                //    goto CheckUsername;
                //}
            }

            gender = profileGender;


            if (string.IsNullOrEmpty(profileAbout))
            {
                about = getAbout(Res_settingPagesource).Replace(" ", "+");
            }
            else
            {
                about = profileAbout;
            }

            if (string.IsNullOrEmpty(profileLocation))
            {
                location = getLocation(Res_settingPagesource);
            }
            else
            {
                location = profileLocation;
            }


            website = getWebsite(Res_settingPagesource).Replace(":", "%3A").Replace("/", "%2F").Trim();  //http%3A%2F%2Fwww.somethingfunny.com%2F

            // string token = getChtoken(res_ProfilePage);

            string status  = "";
            bool   Updated = false;

            try
            {
                //Change Profile Details ....
                //string NewPostData = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22first_name%22%3A%22" + firstname + "%22%2C%22last_name%22%3A%22" + lastname + "%22%2C%22username%22%3A%22" + Username + "%22%2C%22about%22%3A%22" + Uri.EscapeUriString(about) + "%22%2C%22location%22%3A%22" + location + "%22%2C%22website_url%22%3A%22" + Uri.EscapeUriString(website) + "%22%7D%2C%22context%22%3A%7B%22app_version%22%3A%22" + appversion + "%22%2C%22https_exp%22%3Afalse%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)%23Modal(module%3DUserEdit(resource%3DUserSettingsResource()))";

                //string NewPostData = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22first_name%22%3A%22" + firstname + "%22%2C%22last_name%22%3A%22" + lastname + "%22%2C%22username%22%3A%22" + Username + "%22%2C%22about%22%3A%22" + Uri.EscapeUriString(about) + "%22%2C%22location%22%3A%22" + location + "%22%2C%22website_url%22%3A%22" + website + "%22%7D%2C%22context%22%3A%7B%22app_version%22%3A%22" + Uri.EscapeUriString(appversion) + "%22%2C%22https_exp%22%3Afalse%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)%23Modal(module%3DUserEdit(resource%3DUserSettingsResource()))";

                string NewPostData = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22email%22%3A%22" + Uri.EscapeDataString(Email) + "%22%2C%22locale%22%3A%22en-US%22%2C%22country%22%3A%22BQ%22%2C%22gender%22%3A%22" + gender + "%22%2C%22personalize_from_offsite_browsing%22%3Atrue%2C%22first_name%22%3A%22" + firstname + "%22%2C%22last_name%22%3A%22" + Uri.EscapeDataString(lastname) + "%22%2C%22username%22%3A%22" + Username + "%22%2C%22about%22%3A%22" + about + "%22%2C%22location%22%3A%22" + profileLocation + "%22%2C%22website_url%22%3A%22" + Uri.EscapeDataString(website) + "%22%2C%22email_enabled%22%3Atrue%2C%22email_repins%22%3Atrue%2C%22email_likes%22%3Atrue%2C%22email_follows%22%3Atrue%2C%22email_interval%22%3A%22immediate%22%2C%22email_comments%22%3Atrue%2C%22email_shares%22%3Atrue%2C%22email_friends_joining%22%3Atrue%2C%22email_collaboration_invite%22%3Atrue%2C%22email_product_changes%22%3Atrue%2C%22email_suggestions%22%3Atrue%2C%22email_news%22%3Atrue%2C%22email_updates%22%3Atrue%2C%22email_feedback_and_research%22%3Atrue%2C%22exclude_from_search%22%3Afalse%2C%22login_with_facebook%22%3Afalse%2C%22login_with_twitter%22%3Afalse%2C%22connectToGplus%22%3Afalse%2C%22connectToGoogle%22%3Afalse%2C%22connectToYahoo%22%3Afalse%7D%2C%22context%22%3A%7B%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EButton(class_name%3DsaveSettingsButton%2C+color%3Dprimary%2C+type%3Dsubmit%2C+text%3DSave+Settings)";


                //  string NewPostData1="source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22email%22%3A%22"+ Email +"%22%2C%22locale%22%3A%22"+location+"%22%2C%22country%22%3A%22"+Country+"%22%2C%22gender%22%3A%22"+gender+"%22%2C%22personalize_from_offsite_browsing%22%3Atrue%2C%22first_name%22%3A%22"+firstname+"%22%2C%22last_name%22%3A%22"+lastname+"01%22%2C%22username%22%3A%22"+Username+"%22%2C%22about%22%3A%22%22%2C%22location%22%3A%22%22%2C%22"+website+"%22%3A%22%22%2C%22email_enabled%22%3Atrue%2C%22email_repins%22%3Atrue%2C%22email_likes%22%3Atrue%2C%22email_follows%22%3Atrue%2C%22email_interval%22%3A%22immediate%22%2C%22email_comments%22%3Atrue%2C%22email_shares%22%3Atrue%2C%22email_friends_joining%22%3Atrue%2C%22email_collaboration_invite%22%3Atrue%2C%22email_product_changes%22%3Atrue%2C%22email_suggestions%22%3Atrue%2C%22email_news%22%3Atrue%2C%22email_updates%22%3Atrue%2C%22email_feedback_and_research%22%3Atrue%2C%22exclude_from_search%22%3Afalse%2C%22login_with_facebook%22%3Afalse%2C%22login_with_twitter%22%3Afalse%2C%22connectToGplus%22%3Afalse%2C%22connectToGoogle%22%3Afalse%2C%22connectToYahoo%22%3Afalse%7D%2C%22context%22%3A%7B%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EButton(class_name%3DsaveSettingsButton%2C+color%3Dprimary%2C+type%3Dsubmit%2C+text%3DSave+Settings)
                //string newpostdat = "source_url=/settings/&data={\"options\":{\"email\":\"[email protected]\",\"locale\":\"en-US\",\"country\":\"CO\",\"gender\":\"female\",\"personalize_from_offsite_browsing\":true,\"first_name\":\"kavita012\",\"last_name\":\"Gupta1111\",\"username\":\"kavita1112\",\"about\":\"\",\"location\":\"bhilai\",\"website_url\":\"\",\"email_enabled\":true,\"email_repins\":true,\"email_likes\":true,\"email_follows\":true,\"email_interval\":\"immediate\",\"email_comments\":true,\"email_shares\":true,\"email_friends_joining\":true,\"email_collaboration_invite\":true,\"email_product_changes\":true,\"email_suggestions\":true,\"email_news\":true,\"email_updates\":true,\"email_feedback_and_research\":true,\"exclude_from_search\":false,\"login_with_facebook\":false,\"login_with_twitter\":false,\"connectToGplus\":false,\"connectToGoogle\":false,\"connectToYahoo\":false},\"context\":{}}&module_path=App()>UserSettingsPage(resource=UserSettingsResource())>Button(class_name=saveSettingsButton, color=primary, type=submit, text=Save Settings";
                //string NewPostData2 = "source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%22email%22%3A%22kavita1112%40hotmail.com%22%2C%22locale%22%3A%22en-US%22%2C%22country%22%3A%22CO%22%2C%22gender%22%3A%22female%22%2C%22personalize_from_offsite_browsing%22%3Atrue%2C%22first_name%22%3A%22gfgfdg%22%2C%22last_name%22%3A%22gfgfdg%22%2C%22username%22%3A%22kavita11%22%2C%22about%22%3A%22i+am+software+engg%22%2C%22location%22%3A%22bhilai%22%2C%22website_url%22%3A%22%22%2C%22email_enabled%22%3Atrue%2C%22email_repins%22%3Atrue%2C%22email_likes%22%3Atrue%2C%22email_follows%22%3Atrue%2C%22email_interval%22%3A%22immediate%22%2C%22email_comments%22%3Atrue%2C%22email_shares%22%3Atrue%2C%22email_friends_joining%22%3Atrue%2C%22email_collaboration_invite%22%3Atrue%2C%22email_product_changes%22%3Atrue%2C%22email_suggestions%22%3Atrue%2C%22email_news%22%3Atrue%2C%22email_updates%22%3Atrue%2C%22email_feedback_and_research%22%3Atrue%2C%22exclude_from_search%22%3Afalse%2C%22login_with_facebook%22%3Afalse%2C%22login_with_twitter%22%3Afalse%2C%22connectToGplus%22%3Afalse%2C%22connectToGoogle%22%3Afalse%2C%22connectToYahoo%22%3Afalse%7D%2C%22context%22%3A%7B%7D%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EButton(class_name%3DsaveSettingsButton%2C+color%3Dprimary%2C+type%3Dsubmit%2C+text%3DSave+Settings)";
                //string pagesource = globusHttpHelper.postFormData(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/");
                //pagesource = globusHttpHelper.postFormDataProxy(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/", "", 0, "", "");

                string pagesource = globusHttpHelper.postFormData(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/");
                //pagesource = globusHttpHelper.postFormDataProxy(new Uri("https://www.pinterest.com/resource/UserSettingsResource/update/"), NewPostData, "https://www.pinterest.com/settings/", "", 0, "", "");

                //Change profile Image .....

                #region
                //globusHttpHelper.MultiPartImageUploadPreview(Email, language, firstname, lastname, Username, gender, about, location, website, profilePic, CsrfMiddleToken);
                //string pagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com/resource/UserSettingsResource/get/?source_url=%2Fsettings%2F&data=%7B%22options%22%3A%7B%7D%2C%22context%22%3A%7B%22app_version%22%3A%22"+ appversion +"%22%2C%22https_exp%22%3Afalse%7D%2C%22module%22%3A%7B%22name%22%3A%22UserEdit%22%2C%22options%22%3A%7B%22user_id%22%3A%22"+ userid +"%22%7D%7D%2C%22append%22%3Afalse%2C%22error_strategy%22%3A0%7D&module_path=App()%3EUserSettingsPage(resource%3DUserSettingsResource())%3EShowModalButton(module%3DUserEdit)&_=1388476372529") , "" , "" ,"");
                #endregion

                if (!String.IsNullOrEmpty(profilePic))
                {
                    Updated = globusHttpHelper.MultiPartImageUpload_new(Email, language, firstname, lastname, Username, gender, about, location, website, profilePic, CsrfMiddleToken, appversion);
                }
                else
                {
                    Updated = true;
                }
            }
            catch (Exception)
            {
            }

            if (Updated)
            {
                return(Updated);
            }

            return(false);
        }
Пример #4
0
        private List <string> GetStatusIdThroughAjax(ref Globussoft.GlobusHttpHelper globusHttpHelper, string screenName, string MaxId)
        {
            string max_id = MaxId;

repeatAjaxRequests:
            try
            {
                string status = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/i/profiles/show/" + screenName + "/timeline/with_replies?include_available_features=1&include_entities=1&max_id=" + max_id), "", "");

                if (status.Contains(@"/status")) //    /status
                {
                    try
                    {
                        string[] arrStatusId = Regex.Split(status, @"\\\/" + screenName + @"\\\/status\\\/");

                        foreach (string item in arrStatusId)
                        {
                            try
                            {
                                if (!item.Contains("{\"max_id\":"))
                                {
                                    string statusId      = string.Empty;
                                    string statusIdValue = item.Substring(0, 30);
                                    if (statusIdValue.Contains("&"))
                                    {
                                        try
                                        {
                                            statusId = statusIdValue.Substring(2, statusIdValue.IndexOf("&")).Replace("&", string.Empty).Trim();
                                            string[] arrCheckStatusId = Regex.Split(statusId, "[^0-9]");

                                            foreach (string item1 in arrCheckStatusId)
                                            {
                                                try
                                                {
                                                    if (item1.Length > 3)
                                                    {
                                                        lstAjaxStatusId.Add(item1);
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    else
                                    {
                                        try
                                        {
                                            statusId = statusIdValue.Substring(2, statusIdValue.IndexOf("\"", 2)).Replace("\"", string.Empty).Trim();
                                            string[] arrCheckStatusId = Regex.Split(statusId, "[^0-9]");

                                            foreach (string item2 in arrCheckStatusId)
                                            {
                                                try
                                                {
                                                    if (item2.Length > 3)
                                                    {
                                                        lstAjaxStatusId.Add(item2);
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    lstAjaxStatusId = lstAjaxStatusId.Distinct().ToList();
                                }
                            }
                            catch
                            {
                            }
                        }

                        if (status.Contains("max_id\":"))
                        {
                            try
                            {
                                string   max_id1  = status.Substring(status.IndexOf("max_id\":"), status.IndexOf(",", status.IndexOf("max_id\":")) - status.IndexOf("max_id\":")).Replace("max_id\":", string.Empty).Replace("\"", string.Empty).Trim();
                                string[] arrMaxId = Regex.Split(max_id, "[^0-9]");
                                foreach (string item in arrMaxId)
                                {
                                    try
                                    {
                                        if (item.Length > 3)
                                        {
                                            max_id = max_id1;
                                            goto repeatAjaxRequests;
                                            //List<string> lstNextAjaxId = GetStatusIdThroughAjax(ref globusHttpHelper, screenName, item);
                                            //break;
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch
            {
            }
            lstAjaxStatusId = lstAjaxStatusId.Distinct().ToList();
            return(lstAjaxStatusId);
        }
Пример #5
0
        public void GetScrapTweetAndReply(ref Globussoft.GlobusHttpHelper globusHttpHelper, ref string userId, ref string userName, ref string Screen_name, ref string postAuthenticityToken)
        {
            try
            {
                Log("[ " + DateTime.Now + " ] => [ Starting ScrapTweetAndReply.............With User Name : " + UserName + " ]");

                string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + Screen_name), "", "");

                List <string> lstStatusId = GetstatusId(pageSource, globusHttpHelper, ref Screen_name);

                if (lstStatusId.Count > 0)
                {
                    try
                    {
                        int    lastIndex = lstStatusId.Count - 1;
                        string max_Id    = lstStatusId[lastIndex];

                        List <string> lstAjaxStatusId = GetStatusIdThroughAjax(ref globusHttpHelper, Screen_name, max_Id);

                        lstStatusId.AddRange(lstAjaxStatusId);

                        lstStatusId = lstStatusId.Distinct().ToList();
                    }
                    catch
                    {
                    }
                }

                Log("[ " + DateTime.Now + " ] => [ Total StatusId = " + lstStatusId.Count + " With User Name : " + UserName + " ]");

                int counter = 0;

                int countDataBeforeSaving = 0;
                try
                {
                    DataSet ds = obj_clsDB_ReplyInterface.SelectFromtb_ReplyCampaign(StringEncoderDecoder.Encode(UserName));
                    countDataBeforeSaving = ds.Tables[0].Rows.Count;
                }
                catch
                {
                }

                foreach (string item in lstStatusId)
                {
                    try
                    {
                        string url = "https://twitter.com/" + Screen_name + "/status/" + item;

                        string pageSourceOfstatusId = globusHttpHelper.getHtmlfromUrl(new Uri(url), "", "");

                        List <string> lstTweet = GetTweet(globusHttpHelper, pageSourceOfstatusId);

                        List <string> lstTweetUserName = GetTweetUserName(globusHttpHelper, pageSourceOfstatusId);

                        List <string> lstTweetUserId = GetTweetUserId(globusHttpHelper, pageSourceOfstatusId);

                        List <string> lstTweetTime = GetTweetTime(globusHttpHelper, pageSourceOfstatusId);

                        List <string> lstReply = GetReply(globusHttpHelper, pageSourceOfstatusId);

                        List <string> lstReplyUserId = GetReplyUserId(globusHttpHelper, pageSourceOfstatusId);
                        // lstReplyUserId = lstReplyUserId.Distinct().ToList();

                        List <string> lstReplyUserName = GetReplyUserName(globusHttpHelper, pageSourceOfstatusId);

                        List <string> lstReplyTime = GetReplyTime(globusHttpHelper, pageSourceOfstatusId);

                        int index = 0;
                        foreach (string ReplyUserIditem in lstReplyUserId)
                        {
                            try
                            {
                                #region Variable
                                string statusId = string.Empty;
                                string strPostAuthenticityToken = string.Empty;
                                string UserId        = string.Empty;
                                string screenName    = string.Empty;
                                string tweet         = string.Empty;
                                string tweetUserId   = string.Empty;
                                string tweetUserName = string.Empty;
                                string tweetTime     = string.Empty;
                                string reply         = string.Empty;
                                string replyUserId   = string.Empty;
                                string replyUserName = string.Empty;
                                string replyTime     = string.Empty;
                                #endregion

                                if (!string.IsNullOrEmpty(ReplyUserIditem) && !string.IsNullOrWhiteSpace(ReplyUserIditem))
                                {
                                    replyUserId = ReplyUserIditem;

                                    foreach (string Tweetitem in lstTweet)
                                    {
                                        try
                                        {
                                            if (!string.IsNullOrEmpty(Tweetitem) && !string.IsNullOrWhiteSpace(Tweetitem))
                                            {
                                                tweet = Tweetitem;
                                                break;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }

                                    foreach (string TweetUserNameitem in lstTweetUserName)
                                    {
                                        try
                                        {
                                            if (!string.IsNullOrEmpty(TweetUserNameitem) && !string.IsNullOrWhiteSpace(TweetUserNameitem))
                                            {
                                                tweetUserName = TweetUserNameitem;
                                                break;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }

                                    foreach (string TweetUserIditem in lstTweetUserId)
                                    {
                                        try
                                        {
                                            if (!string.IsNullOrEmpty(TweetUserIditem) && !string.IsNullOrWhiteSpace(TweetUserIditem))
                                            {
                                                tweetUserId = TweetUserIditem;
                                                break;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }

                                    foreach (string lstTweetTimeitem in lstTweetTime)
                                    {
                                        try
                                        {
                                            if (!string.IsNullOrEmpty(lstTweetTimeitem) && !string.IsNullOrWhiteSpace(lstTweetTimeitem))
                                            {
                                                tweetTime = lstTweetTimeitem;
                                                break;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }

                                    try
                                    {
                                        reply = lstReply[index];
                                    }
                                    catch
                                    {
                                    }

                                    try
                                    {
                                        replyUserName = lstReplyUserName[index];
                                    }
                                    catch
                                    {
                                    }

                                    try
                                    {
                                        replyTime = lstReplyTime[index];
                                    }
                                    catch
                                    {
                                    }

                                    index++;


                                    statusId = item;

                                    strPostAuthenticityToken = postAuthenticityToken;

                                    UserId = userId;

                                    UserName = userName;

                                    screenName = Screen_Name;

                                    if (!string.IsNullOrEmpty(statusId) && !string.IsNullOrWhiteSpace(statusId) && !string.IsNullOrEmpty(UserName) && !string.IsNullOrWhiteSpace(UserName) && !string.IsNullOrEmpty(replyUserId) && !string.IsNullOrWhiteSpace(replyUserId) && !string.IsNullOrEmpty(replyUserName) && !string.IsNullOrWhiteSpace(replyUserName) && !string.IsNullOrEmpty(reply) && !string.IsNullOrWhiteSpace(reply) && !string.IsNullOrEmpty(strPostAuthenticityToken) && !string.IsNullOrWhiteSpace(strPostAuthenticityToken)) //!string.IsNullOrEmpty(UserId) && !string.IsNullOrWhiteSpace(UserId) &&
                                    {
                                        try
                                        {
                                            DataSet ds = obj_clsDB_ReplyInterface.SelectStatusIdUserNameTweetAndReplyFromtb_ReplyCampaign(StringEncoderDecoder.Encode(statusId), StringEncoderDecoder.Encode(UserName), StringEncoderDecoder.Encode(tweet), StringEncoderDecoder.Encode(reply));

                                            if (ds.Tables[0].Rows.Count < 1)
                                            {
                                                obj_clsDB_ReplyInterface.InserIntotb_ReplyCampaign(StringEncoderDecoder.Encode(statusId), StringEncoderDecoder.Encode(strPostAuthenticityToken), StringEncoderDecoder.Encode(UserId), StringEncoderDecoder.Encode(userName), StringEncoderDecoder.Encode(screenName), StringEncoderDecoder.Encode(tweetUserId), StringEncoderDecoder.Encode(tweetUserName), StringEncoderDecoder.Encode(replyUserId), StringEncoderDecoder.Encode(replyUserName), StringEncoderDecoder.Encode(tweet), StringEncoderDecoder.Encode(tweetTime), StringEncoderDecoder.Encode(reply), StringEncoderDecoder.Encode(replyTime), StringEncoderDecoder.Encode('0'.ToString()));

                                                counter++;
                                                Log("[ " + DateTime.Now + " ] => [ " + counter + " Record Saved In Data Base With User Name : " + UserName + " ]");
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                int countDataAfterSaving = 0;
                try
                {
                    DataSet ds = obj_clsDB_ReplyInterface.SelectFromtb_ReplyCampaign(StringEncoderDecoder.Encode(UserName));
                    countDataAfterSaving = ds.Tables[0].Rows.Count;



                    if (countDataBeforeSaving == countDataAfterSaving)
                    {
                        Log("[ " + DateTime.Now + " ] => [ No New Reply With User Name : " + userName + " ] ");
                    }
                }
                catch
                {
                }

                Log("[ " + DateTime.Now + " ] => [ PROCESS COMPLTED With User Name : " + userName + " ]");
                Log("------------------------------------------------------------------------------------------------------------------------------------------");
            }
            catch
            {
            }
        }
Пример #6
0
        public void Tweet(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string tweetMessage, out string status)
        {
            string tweetdata  = string.Empty;
            string tweetUrl   = string.Empty;
            string postaTweet = string.Empty;

            try
            {
                //string abc = tweetMessage.Replace("�", " ");
                //Post Tweet To Account
                tweetdata = "authenticity_token=" + postAuthenticityToken + "&place_id=&status=" + Uri.EscapeDataString(tweetMessage);
                tweetUrl  = "https://twitter.com/i/tweet/create";

                postaTweet = globusHttpHelper.postFormData(new Uri(tweetUrl), tweetdata, "https://twitter.com/", "XMLHttpRequest", "", "", "");


                ///Old Twitter 1.0 API code
                //string TweetData = "include_entities=true&status=" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + postAuthenticityToken;
                //string res_PostTweet = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), TweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", "");
                /////

                var message = (Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(postaTweet))["message"];

                //string ss=Uri.en

                if (postaTweet.Contains("Your Tweet was posted!") || message.ToString().Contains("आपका ट्वीट पोस्ट हो गया") || postaTweet.Contains("tweet_id") || message.Contains("tweet_id") || message.ToString().Contains("Your Tweet was posted!") || postaTweet.Contains(message.ToString()))
                {
                    status = "posted";
                }
                else if (postaTweet.Contains("Your Tweet to") && postaTweet.Contains("has been sent"))
                {
                    status = "posted";
                }

                else
                {
                    status = "not posted";
                }
            }
            catch (Exception ex)
            {
                try
                {
                    if (ex.Message.Contains("Stream was not readable"))
                    {
                        if (!string.IsNullOrEmpty(Globals.DBCUsername) && !string.IsNullOrEmpty(Globals.DBCPassword))
                        {
                            string _tempCaptcha     = globusHttpHelper.getHtmlfromUrl(new Uri("https://www.google.com/recaptcha/api/challenge?k=6LfbTAAAAAAAAE0hk8Vnfd1THHnn9lJuow6fgulO&ajax=1&cachestop=0.88776721409522&lang=en"), "", "");
                            string captchaChallenge = globusHttpHelper.getBetween(_tempCaptcha, "challenge : '", ",").Replace("challenge : '", "").Replace("'", "");
                            string ImageUrl         = "https://www.google.com/recaptcha/api/image?c=" + captchaChallenge;

                            WebClient webclient   = new WebClient();
                            string    captchaText = string.Empty;
                            if (!string.IsNullOrEmpty(captchaChallenge))
                            {
                                try
                                {
                                    //WebIP IPObj = new WebIP("http://192.227.234.242:80");
                                    //IPObj.Credentials = CredentialCache.DefaultCredentials;
                                    //webclient.IP = IPObj;

                                    byte[] args = webclient.DownloadData(ImageUrl);

                                    string[] arr1 = new string[] { Globals.DBCUsername, Globals.DBCPassword, "" };

                                    captchaText = DecodeDBC(arr1, args);
                                }
                                catch { }
                            }

                            if (!string.IsNullOrEmpty(captchaText))
                            {
                                string mainUrl  = "https://twitter.com/account/challenge?challenge=" + captchaChallenge + "&challenge_name=Captcha&response=" + captchaText.Replace(" ", "+");
                                string response = globusHttpHelper.getHtmlfromUrl(new Uri(mainUrl), "", "", "");

                                postaTweet = globusHttpHelper.postFormData(new Uri(tweetUrl), tweetdata, "https://twitter.com/", "XMLHttpRequest", "", "", "");

                                var message = (Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(postaTweet))["message"];

                                //string ss=Uri.en

                                if (postaTweet.Contains("Your Tweet was posted!") || message.ToString().Contains("आपका ट्वीट पोस्ट हो गया") || postaTweet.Contains("tweet_id") || message.Contains("tweet_id") || message.ToString().Contains("Your Tweet was posted!") || postaTweet.Contains(message.ToString()))
                                {
                                    status = "posted";
                                }
                                else if (postaTweet.Contains("Your Tweet to") && postaTweet.Contains("has been sent"))
                                {
                                    status = "posted";
                                }

                                else
                                {
                                    status = "not posted";
                                }
                            }
                            else
                            {
                                status = "not posted";
                            }
                        }
                        else
                        {
                            status = "not posted";
                        }
                    }
                    else
                    {
                        status = "not posted";
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() -- Tweet() --> " + ex.Message, Globals.Path_FollowerErroLog);
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() -- Tweet()  --> " + ex.Message, Globals.Path_TwtErrorLogs);
                    }
                }
                catch (Exception exp)
                {
                    status = "not posted";
                    Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() -- Tweet() --> " + exp.Message, Globals.Path_FollowerErroLog);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Change follow code  after API change
        /// </summary>
        /// <param name="thisHttpHelpr"></param>
        /// <param name="ForeignhttpHelpr"></param>

        #region FollowUsingProfileID_New
        public void FollowUsingProfileID_New(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toFollow, out string status)
        {
            try
            {
                string data_user_id = string.Empty;
                string PostData     = string.Empty;

                if (NumberHelper.ValidateNumber(user_id_toFollow))
                {
                    string tempScreenName = string.Empty;
                    data_user_id = user_id_toFollow;
                    string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/intent/user?user_id=" + user_id_toFollow), "", "");
                    if (string.IsNullOrEmpty(pageSource))
                    {
                        pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/intent/user?user_id=" + user_id_toFollow), "", "");
                    }
                    tempScreenName = globusHttpHelper.getBetween(pageSource, "<span class=\"name\">", "</span>");
                    if (!string.IsNullOrEmpty(tempScreenName))
                    {
                        pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + tempScreenName), "", "");
                    }

                    if (!string.IsNullOrEmpty(pageSource))
                    {
                        try
                        {
                            int startIndx = pageSource.IndexOf("data-user-id=\"") + "data-user-id=\"".Length;
                            int endIndx   = pageSource.IndexOf("\"", startIndx);
                            userID = pageSource.Substring(startIndx, endIndx - startIndx);
                        }
                        catch { }

                        if (string.IsNullOrEmpty(userID))
                        {
                            userID = string.Empty;
                            //string[] useridarr = System.Text.RegularExpressions.Regex.Split(pageSource, "data-user-id="); //account-group js-mini-current-user
                            string[] useridarr = System.Text.RegularExpressions.Regex.Split(pageSource, "account-group js-mini-current-user");
                            //foreach (string useridarr_item in useridarr)
                            //{
                            //    if (useridarr_item.Contains("data-screen-name="))
                            //    {
                            //        userID = useridarr_item.Substring(0 + 1, useridarr_item.IndexOf("data-screen-name=") - 3);
                            //        break;
                            //    }
                            //}

                            try
                            {
                                userID = Utils.getBetween(useridarr[1], "data-user-id=\"", "\"");
                            }
                            catch { };
                        }
                    }
                }
                else
                {
                    try
                    {
                        string data_id    = string.Empty;
                        string pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + user_id_toFollow), "", "");
                        if (string.IsNullOrEmpty(pageSource))
                        {
                            pageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + user_id_toFollow), "", "");
                        }

                        try
                        {
                            int startIndx = pageSource.IndexOf("data-user-id=\"") + "data-user-id=\"".Length;
                            int endIndx   = pageSource.IndexOf("\"", startIndx);
                            userID = pageSource.Substring(startIndx, endIndx - startIndx);
                            if (string.IsNullOrEmpty(userID))
                            {
                                try
                                {
                                    //string[] GetUserId = System.Text.RegularExpressions.Regex.Split(pageSource, "user-actions btn-group not-following not-muting");
                                    string[] useridarr = System.Text.RegularExpressions.Regex.Split(pageSource, "account-group js-mini-current-user");

                                    try
                                    {
                                        userID = Utils.getBetween(useridarr[1], "data-user-id=\"", "\"");
                                    }
                                    catch { };
                                }
                                catch { };
                            }
                        }
                        catch { }

                        if (string.IsNullOrEmpty(userID))
                        {
                            userID = string.Empty;
                            string[] useridarr = System.Text.RegularExpressions.Regex.Split(pageSource, "data-user-id=");
                            foreach (string useridarr_item in useridarr)
                            {
                                if (useridarr_item.Contains("data-screen-name="))
                                {
                                    userID = useridarr_item.Substring(0 + 1, useridarr_item.IndexOf("data-screen-name=") - 3);
                                    break;
                                }
                            }
                        }


                        if (globusHttpHelper.gResponse.ResponseUri.ToString().Contains("suspended"))
                        {
                            status = "not followed";
                            Log(user_id_toFollow + " :-  Account is suspended ");
                            return;
                        }

                        string[] data_id1 = System.Text.RegularExpressions.Regex.Split(pageSource, "data-user-id=");
                        if (pageSource.Contains("js-stream-item stream-item stream-item"))
                        {
                            if (pageSource.Contains("profile-card-inner"))
                            {
                                int    startindex = pageSource.IndexOf("profile-card-inner");
                                string start      = pageSource.Substring(startindex).Replace("profile-card-inner", "");
                                int    endindex   = start.IndexOf("\">");
                                string end        = start.Substring(start.IndexOf("data-user-id="), endindex - start.IndexOf("data-user-id=")).Replace("data-user-id=", "").Replace("\"", "");
                                data_user_id = end.Trim();
                            }
                            else
                            {
                                try
                                {
                                    //int startindex = pageSource.IndexOf("ProfileTweet-authorDetails\">");
                                    //string start = pageSource.Substring(startindex).Replace("ProfileTweet-authorDetails\">", "");
                                    //int endindex = start.IndexOf("\">");
                                    //string end = start.Substring(start.IndexOf("data-user-id="), endindex - start.IndexOf("data-user-id=")).Replace("data-user-id=", "").Replace("\"", "");
                                    //data_user_id = end.Trim();

                                    string[] getDataUserID = System.Text.RegularExpressions.Regex.Split(pageSource, "ProfileNav");
                                    data_user_id = Utils.getBetween(getDataUserID[1], "data-user-id=\"", "\"");
                                }
                                catch { };
                            }
                        }
                        else
                        {
                            try
                            {
                                int    startindex = pageSource.IndexOf("profile_id");
                                string start      = pageSource.Substring(startindex).Replace("profile_id", "");
                                int    endindex   = start.IndexOf(",");
                                string end        = start.Substring(0, endindex).Replace("&quot;", "").Replace("\"", "").Replace(":", "").Trim();
                                data_user_id = end.Trim();
                            }
                            catch { }

                            if (string.IsNullOrEmpty(data_user_id))
                            {
                                try
                                {
                                    int    startindex = pageSource.IndexOf("ProfileTweet-authorDetails\">");
                                    string start      = pageSource.Substring(startindex).Replace("ProfileTweet-authorDetails\">", "");
                                    int    endindex   = start.IndexOf("\">");
                                    string end        = start.Substring(start.IndexOf("data-user-id="), endindex - start.IndexOf("data-user-id=")).Replace("data-user-id=", "").Replace("\"", "");
                                    data_user_id = end.Trim();
                                }
                                catch { }
                            }

                            if (string.IsNullOrEmpty(data_user_id))
                            {
                                try
                                {
                                    int startindex = pageSource.IndexOf("stats js-mini-profile-stats \" data-user-id=\"");
                                    if (startindex == -1)
                                    {
                                        startindex = pageSource.IndexOf("user-actions btn-group not-following not-muting \" data-user-id=\"");
                                    }
                                    if (startindex == -1)
                                    {
                                        startindex = pageSource.IndexOf("user-actions btn-group not-following not-muting protected\" data-user-id=\"");
                                    }
                                    string start = pageSource.Substring(startindex).Replace("stats js-mini-profile-stats \" data-user-id=\"", "").Replace("user-actions btn-group not-following not-muting \" data-user-id=\"", "").Replace("user-actions btn-group not-following not-muting protected\" data-user-id=\"", "").Trim();
                                    //int endindex = start.IndexOf("\">");
                                    int    endindex = start.IndexOf("\"");
                                    string end      = start.Substring(0, endindex);
                                    data_user_id = end.Replace("\"", "");
                                }
                                catch { }
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID1()-->  " + err.Message, Globals.Path_FollowerErroLog);
                    }
                }
                DataSet dt            = DataBaseHandler.SelectQuery("SELECT * FROM tb_user_follower_details Where followerId = '" + data_user_id + "' and userId = '" + userID + "' ", "tb_user_follower_details");
                int     count_NO_RoWs = dt.Tables[0].Rows.Count;
                if (count_NO_RoWs == 0)
                {
                    if (!string.IsNullOrEmpty(data_user_id))
                    {
                        PostData = "authenticity_token=" + postAuthenticityToken + "&user_id=" + data_user_id;
                        string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/user/follow"), PostData, "https://twitter.com/" + user_id_toFollow, string.Empty, "XMLHttpRequest", "true", "");

                        try
                        {
                            if (!string.IsNullOrEmpty(user_id_toFollow) && !string.IsNullOrEmpty(data_user_id))
                            {
                                // string query = "INSERT INTO tb_UsernameDetails (Username , Userid) VALUES ('" + user_id_toFollow + "' ,'" + data_user_id + "') ";
                                string query = "INSERT INTO  tb_user_follower_details (followerName,followerId,userId) VALUES ('" + user_id_toFollow + "' ,'" + data_user_id + "','" + userID + "') ";
                                DataBaseHandler.InsertQuery(query, "tb_UsernameDetails");
                            }
                        }
                        catch (Exception ex)
                        {
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID_New() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_FollowerErroLog);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> FollowUsingProfileID_New() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }
                        status = "followed";
                        if (res_PostFollow.Contains("pending"))
                        {
                            status = "pending";
                        }
                        else if (res_PostFollow.Contains("following"))
                        {
                            status = "followed";
                        }
                    }
                    else
                    {
                        status = "not followed";
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID1()(User ID is null) ", Globals.Path_FollowerErroLog);
                    }
                }
                else
                {
                    status = "Already Followed";
                    Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID1()--> DataBase Insert error ", Globals.Path_FollowerErroLog);
                    return;
                }
            }
            catch (Exception ex)
            {
                status = "not followed";
                //Log("Method>>  FollowUsingProfileID  --- class>>  Follower.cs : Follow Exception " + ex.Message);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_FollowerErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
        public static bool GetStatusLinks(string username)
        {
            int counter = 0;
            Globussoft.GlobusHttpHelper httpHelper = new Globussoft.GlobusHttpHelper();
            string user_id = string.Empty;
            bool tooManyLinks = true;
            try
            {
                string text = 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/statuses/user_timeline.xml?include_entities=true&inc%E2%80%8C%E2%80%8Blude_rts=true&include_rts=1&user_id=" + username + "&count=" + noOfstatus), "", "");
                }
                else
                {
                    PageSource = httpHelper.getHtmlfromUrl(new Uri("https://api.twitter.com/1/statuses/user_timeline.xml?include_entities=true&inc%E2%80%8C%E2%80%8Blude_rts=true&include_rts=1&screen_name=" + username + "&count=" + noOfstatus), "", "");
                }

                if (!string.IsNullOrEmpty(PageSource) && PageSource.Contains("Sorry, that page does not exist"))
                {
                    return tooManyLinks;
                }

                if (!string.IsNullOrEmpty(PageSource))
                {
                    string[] statusArray = Regex.Split(PageSource, "<status>");
                    statusArray = statusArray.Skip(1).ToArray();

                    foreach (string Status in statusArray)
                    {
                        try
                        {
                            int indexStart = Status.IndexOf("<text>");
                            if (Status.Contains("<profile_image_url>"))
                            {
                                string start = Status.Substring(indexStart);
                                int endIndex = start.IndexOf("</text>");
                                string end = start.Substring(0, endIndex);
                                text = end.Replace("<text>", "");
                            }

                            List<string> GetHrefs = GlobusRegex.GetHrefsFromString(text);

                            if (GetHrefs.Count >= 1)
                            {
                                counter++;
                            }

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

                    //FollowingsFollowersRatio_user_id = (count_Followings_user_id * 100) / count_Followers_user_id;
                    int PerLinks = (counter * 100) / 20;
                    //double PerLinks = a * 100;

                    if (PerLinks > Percentage)
                    {
                        tooManyLinks = false;
                    }
                }
                else
                {
                    tooManyLinks = false;
                }

            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
            return tooManyLinks;
        }
Пример #9
0
        public List <string> ExtractFriendIDs(ref Globussoft.GlobusHttpHelper HttpHelper, ref string userID)
        {
            string pgSrc_HomePage = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/"));
            string ProFileURL     = string.Empty;

            string UserId = string.Empty;

            #region Get User or Account ID
            if (pgSrc_HomePage.Contains("http://www.facebook.com/profile.php?id="))
            {
                ///Modified Sumit [10-12-2011]
                #region

                int startIndx = pgSrc_HomePage.IndexOf("http://www.facebook.com/profile.php?id=");
                int endIndx   = pgSrc_HomePage.IndexOf("\"", startIndx + 1);
                ProFileURL = pgSrc_HomePage.Substring(startIndx, endIndx - startIndx);
                if (ProFileURL.Contains("&"))
                {
                    string[] Arr = ProFileURL.Split('&');
                    ProFileURL = Arr[0];
                }

                #endregion
            }
            if (ProFileURL.Contains("http://www.facebook.com/profile.php?id="))
            {
                UserId = ProFileURL.Replace("http://www.facebook.com/profile.php?id=", "");
                if (UserId.Contains("&"))
                {
                    UserId = UserId.Remove(UserId.IndexOf("&"));
                }
                userID = UserId;
            }
            #endregion

            List <string> lstFriend         = new List <string>();
            string        pgSrc_FriendsPage = HttpHelper.getHtmlfromUrl(new Uri("http://www.facebook.com/profile.php?id=" + UserId + "&sk=friends&v=friends"));
            if (pgSrc_FriendsPage.Contains("http://www.facebook.com/profile.php?id="))
            {
                string[] arr = Regex.Split(pgSrc_FriendsPage, "href");
                foreach (string strhref in arr)
                {
                    if (!strhref.Contains("<!DOCTYPE"))
                    {
                        if (strhref.Contains("profile.php?id"))
                        {
                            int startIndx = strhref.IndexOf("profile.php?id") + "profile.php?id".Length + 1;
                            int endIndx   = strhref.IndexOf("\"", startIndx);

                            string profileID = strhref.Substring(startIndx, endIndx - startIndx);

                            if (profileID.Contains("&"))
                            {
                                profileID = profileID.Remove(profileID.IndexOf("&"));
                            }
                            if (profileID.Contains("\\"))
                            {
                                profileID = profileID.Replace("\\", "");
                            }
                            lstFriend.Add(profileID);
                        }
                    }
                }
            }
            List <string> itemId = lstFriend.Distinct().ToList();
            return(itemId);
        }
Пример #10
0
        public List <StructTweetIDs> KeywordStructData(string keyword)
        {
            try
            {
                int counter = 0;
                lst_structTweetIDs = new List <StructTweetIDs>();
                string res_Get_searchURL = string.Empty;

                string searchURL = "https://twitter.com/phoenix_search.phoenix?q=" + keyword + "&count=" + noOfRecords + "&include_entities=1&include_available_features=1&contributor_details=true&page=null&mode=relevance&query_source=typed_query";


                try
                {
                    res_Get_searchURL = globushttpHelper.getHtmlfromUrl(new Uri(searchURL), "", "");
                }
                catch (Exception ex)
                {
                    System.Threading.Thread.Sleep(2000);
                    res_Get_searchURL = globushttpHelper.getHtmlfromUrl(new Uri(searchURL), "", "");
                    Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + keyword + " --  res_Get_searchURL --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                    Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + keyword + " -- res_Get_searchURL --> " + ex.Message, Globals.Path_TwtErrorLogs);
                }

                if (!string.IsNullOrEmpty(res_Get_searchURL))
                {
                    string[] splitRes = Regex.Split(res_Get_searchURL, "\"in_reply_to_status_id_str\"");//Regex.Split(res_Get_searchURL, "{\"created_at\"");

                    splitRes = splitRes.Skip(1).ToArray();

                    foreach (string item in splitRes)
                    {
                        if (noOfRecords > counter)
                        {
                            counter++;
                        }
                        else
                        {
                            break;
                        }
                        string modified_Item = "\"from_user\"" + item;

                        string id = "";
                        try
                        {
                            int    startIndex = item.IndexOf("\"id_str\"");
                            string start      = item.Substring(startIndex);
                            int    endIndex   = start.IndexOf("\",");
                            string end        = start.Substring(0, endIndex).Replace("id_str", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("}", "").Replace("]", "");
                            id = end;
                        }
                        catch (Exception ex)
                        {
                            id = "null";
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- id -- " + keyword + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- id -- " + keyword + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }

                        string from_user_id = "";
                        try
                        {
                            int    startIndex = item.IndexOf("\"id\"");
                            string start      = item.Substring(startIndex);
                            int    endIndex   = start.IndexOf(",\"");
                            string end        = start.Substring(0, endIndex).Replace("id", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("_str", "").Replace("user", "").Replace("}", "").Replace("]", "");
                            from_user_id = end;
                        }
                        catch (Exception ex)
                        {
                            from_user_id = "null";
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + keyword + " -- from_user_id --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + keyword + " -- from_user_id --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }

                        string from_user = "";
                        try
                        {
                            int    startindex = item.IndexOf("\"screen_name\"");
                            string start      = item.Substring(startindex);
                            int    endIndex   = start.IndexOf(",\"");
                            string end        = start.Substring(0, endIndex).Replace("screen_name", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("}", "").Replace("]", "");
                            from_user = end;
                        }
                        catch (Exception ex)
                        {
                            from_user_id = "null";
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + keyword + " -- from_user --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + keyword + " -- from_user --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }

                        string text = string.Empty;

                        try
                        {
                            int    startindex = item.IndexOf("\"text\":");
                            string start      = item.Substring(startindex).Replace("\"text\":", "");
                            int    endIndex   = start.IndexOf(",\"");
                            string end        = start.Substring(0, endIndex).Replace("screen_name", "").Replace("\"", "").Replace(":", "").Replace("{", "").Replace("}", "");
                            text = end;
                        }
                        catch (Exception ex)
                        {
                            from_user_id = "null";
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + keyword + " -- from_user --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + keyword + " -- from_user --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }

                        StructTweetIDs structTweetIDs = new StructTweetIDs();

                        if (id != "null")
                        {
                            structTweetIDs.ID_Tweet             = id;
                            structTweetIDs.ID_Tweet_User        = from_user_id;
                            structTweetIDs.username__Tweet_User = from_user;
                            structTweetIDs.wholeTweetMessage    = text;

                            lst_structTweetIDs.Add(structTweetIDs);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetPhotoFromUsername() -- " + keyword + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetPhotoFromUsername() -- " + keyword + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }

            return(lst_structTweetIDs);
        }
Пример #11
0
        public static bool GetStatusLinks(string username)
        {
            int counter = 0;

            Globussoft.GlobusHttpHelper httpHelper = new Globussoft.GlobusHttpHelper();
            string user_id      = string.Empty;
            bool   tooManyLinks = true;

            try
            {
                string text       = 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/statuses/user_timeline.xml?include_entities=true&inc%E2%80%8C%E2%80%8Blude_rts=true&include_rts=1&user_id=" + username + "&count=" + noOfstatus), "", "");
                }
                else
                {
                    PageSource = httpHelper.getHtmlfromUrl(new Uri("https://api.twitter.com/1/statuses/user_timeline.xml?include_entities=true&inc%E2%80%8C%E2%80%8Blude_rts=true&include_rts=1&screen_name=" + username + "&count=" + noOfstatus), "", "");
                }

                if (!string.IsNullOrEmpty(PageSource) && PageSource.Contains("Sorry, that page does not exist"))
                {
                    return(tooManyLinks);
                }

                if (!string.IsNullOrEmpty(PageSource))
                {
                    string[] statusArray = Regex.Split(PageSource, "<status>");
                    statusArray = statusArray.Skip(1).ToArray();

                    foreach (string Status in statusArray)
                    {
                        try
                        {
                            int indexStart = Status.IndexOf("<text>");
                            if (Status.Contains("<profile_image_url>"))
                            {
                                string start    = Status.Substring(indexStart);
                                int    endIndex = start.IndexOf("</text>");
                                string end      = start.Substring(0, endIndex);
                                text = end.Replace("<text>", "");
                            }

                            List <string> GetHrefs = GlobusRegex.GetHrefsFromString(text);

                            if (GetHrefs.Count >= 1)
                            {
                                counter++;
                            }
                        }
                        catch (Exception ex)
                        {
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                            Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
                        }
                    }

                    //FollowingsFollowersRatio_user_id = (count_Followings_user_id * 100) / count_Followers_user_id;
                    int PerLinks = (counter * 100) / 20;
                    //double PerLinks = a * 100;

                    if (PerLinks > Percentage)
                    {
                        tooManyLinks = false;
                    }
                }
                else
                {
                    tooManyLinks = false;
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetStatusLinks() -- " + username + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
            return(tooManyLinks);
        }