Example #1
0
        //Code added by Lijo For tweeting with images in the wait and reply module
        public void TweetMessageWithImage(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string tweetMessage, string ImageFilePath, out string status)
        {
            string status1     = string.Empty;
            bool   IsLocalFile = true;
            string MediaId     = string.Empty;

            ///Read Image Data in Byte
            ///convert byte in base 64 string
            try
            {
                string _base64String = Convert.ToBase64String(File.ReadAllBytes(ImageFilePath));

                try
                {
                    _base64String = StringEncoderDecoder.EncodeBase64String(_base64String);
                }
                catch
                {
                }
                ///call method for posting
                ///
                string txid = (UnixTimestampFromDateTime(System.DateTime.Now) * 1000).ToString();

                string postData  = "authenticity_token=" + postAuthenticityToken + "&iframe_callback=&media=" + _base64String + "&upload_id=" + txid + "&origin=https%3A%2F%2Ftwitter.com";
                string response_ = globusHttpHelper.postFormData(new Uri("https://upload.twitter.com/i/media/upload.iframe?origin=https%3A%2F%2Ftwitter.com"), postData, "https://twitter.com/", "", "", "", "https://twitter.com/");

                MediaId = globusHttpHelper.getBetween(response_, "snowflake_media_id\":", ",").Replace("snowflake_media_id\":", "").Trim();

                string finalpostdata = "authenticity_token=" + postAuthenticityToken + "&media_ids=" + MediaId + "&place_id=&status=" + tweetMessage.Replace(" ", "+") + "&tagged_users=";

                response_ = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/tweet/create"), finalpostdata, "https://twitter.com/", "", "XMLHttpRequest", "", "https://twitter.com/");

                //globusHttpHelper.HttpUploadImageFileWithMessage("https://upload.twitter.com/i/tweet/create_with_media.iframe", ImageFilePath, "media_data[]", "application/octet-stream", nvc, true, ref status1);

                //if (status1 == "okay")
                //{
                //    status1 = "posted";
                //}

                if (response_.Contains("tweet_id"))
                {
                    status1 = "posted";
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetMessageWithImagePostData() -- Tweet -- que_TweetMessages_Hashtags --> " + ex.Message, Globals.Path_TweetingErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetMessageWithImagePostData() --  Tweet -- que_TweetMessages_Hashtags  --> " + ex.Message, Globals.Path_TweetAccountManager);
            }
            status = status1;
        }
Example #2
0
        public void FavoriteByUrl(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string retweetID, out string status)
        {
            try
            {
                //Post Tweet To Account

                //authenticity_token=8a67c8aeefc40985cd2ce4cd0ff01a9ae17b5dd2&id=277327596696518656

                string ReTweetData      = "authenticity_token=" + postAuthenticityToken + "&id=" + retweetID;
                string ReTweetPostUrl   = "https://twitter.com/i/tweet/favorite";
                string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "", postAuthenticityToken, "XMLHttpRequest", "true", "");

                if (res_Post_Retweet.Contains("\"stat\":\"favorite\""))
                {
                    status = "posted";
                }
                else
                {
                    status = "not posted";
                }
            }
            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);
            }
        }
Example #3
0
        public void Reply(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetID, string screenName, string tweetMessage, out string status)
        {
            try
            {
                //https://twitter.com/i/tweet/create
                string TweetId        = tweetID;                                                                                                                                                               //"197551187803906048";
                string ReplyData      = "authenticity_token=" + postAuthenticityToken + "&in_reply_to_status_id=" + TweetId + "&place_id=&status=%40" + screenName + "+" + Uri.EscapeDataString(tweetMessage); //"in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + "screenname to reply to" + "+" + tweetMessage + "&post_authenticity_token=" + postAuthenticityToken;
                string res_Post_Reply = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/tweet/create"), ReplyData, "https://twitter.com/" + screenName + "/status/" + tweetID, postAuthenticityToken, "XMLHttpRequest", "true", "");

                status = "posted";
                ///Reply For twitter api 1.0
                //string TweetId = tweetID;// "197682704844734464";
                //string ReTweetData = "post_authenticity_token=" + postAuthenticityToken;
                //string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json";
                //string a6 = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", "");
                //string TweetId = tweetID;//"197551187803906048";
                //string ReplyData = "in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + screenName + "+" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + postAuthenticityToken; ;//"in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + "screenname to reply to" + "+" + tweetMessage + "&post_authenticity_token=" + postAuthenticityToken;
                //string res_Post_Reply = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), ReplyData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", "");
            }
            catch (Exception ex)
            {
                status = "not posted";
                //Log("Method>>  Reply  --- class>>  Tweeter.cs : Reply Exception " + ex.Message);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply() --> " + ex.Message, Globals.Path_TweetingErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Reply() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
Example #4
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);
            }
        }
Example #5
0
        public void ReTweet(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetID, string tweetMessage, out string status)
        {
            try
            {
                //Post Tweet To Account
                //ReTweet 0

                string strpostAuthenticityToken = string.Empty;

                string get_twitter_first = globusHttpHelper.getHtmlfromUrlIP(new Uri("https://twitter.com/"), IPAddress, IPPort, IPUsername, IPpassword, string.Empty, string.Empty);

                if (!string.IsNullOrEmpty(get_twitter_first) && !string.IsNullOrWhiteSpace(get_twitter_first))
                {
                    // strpostAuthenticityToken = PostAuthenticityToken(get_twitter_first, "postAuthenticityToken");
                }

                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";
            }
            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);
            }
        }
Example #6
0
        public void UnFollowUsingProfileID(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toUnFollow, out string status)
        {
            string currentStatus = string.Empty;

            try
            {
                string unfollowpostdata = "authenticity_token=" + postAuthenticityToken + "&user_id=" + user_id_toUnFollow.Trim();// + user_id_toUnFollow;
                //string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/user/unfollow"), unfollowpostdata, "https://api.twitter.com/receiver.html", string.Empty, "XMLHttpRequest", "true", "https://api.twitter.com");
                string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/user/unfollow"), unfollowpostdata, "https://twitter.com/following", string.Empty, "XMLHttpRequest", "true", "");

                //if (res_PostFollow.EndsWith("new_state\":\"not-following\"}"))
                if (res_PostFollow.StartsWith("{\"new_state\":\"not-following") || res_PostFollow.EndsWith("new_state\":\"not-following\"}"))
                {
                    currentStatus = "Unfollowed";
                }
                else if (res_PostFollow.StartsWith("{\"new_state\":\"not-following"))
                {
                    currentStatus = "Already Unfollowed";
                }
                else
                {
                    currentStatus = "not Unfollowed";
                }
                status = currentStatus;
            }
            catch (Exception ex)
            {
                status = "not Unfollowed";
                //Log("[ " + DateTime.Now + " ] => [ Method>>  UnFollowUsingProfileID  --- class>>  Unfollower.cs : UnFollow Exception " + ex.Message + " ]");
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Unfollower -- UnFollowUsingProfileID() --> " + ex.Message, Globals.Path_UnfollowerErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Unfollower -- UnFollowUsingProfileID() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
Example #7
0
        public void Tweet(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetMessage, out string status)
        {
            try
            {
                //string abc = tweetMessage.Replace("�", " ");
                //Post Tweet To Account
                string strpostAuthenticityToken = string.Empty;

                string get_twitter_first = globusHttpHelper.getHtmlfromUrlIP(new Uri("https://twitter.com/"), IPAddress, IPPort, IPUsername, IPpassword, string.Empty, string.Empty);

                if (!string.IsNullOrEmpty(get_twitter_first) && !string.IsNullOrWhiteSpace(get_twitter_first))
                {
                    strpostAuthenticityToken = PostAuthenticityToken(get_twitter_first, "postAuthenticityToken");
                }

                if (!string.IsNullOrEmpty(tweetMessage) && !string.IsNullOrWhiteSpace(tweetMessage))
                {
                    if (tweetMessage.Length > 140)
                    {
                        int index = tweetMessage.Length - 140;
                        tweetMessage = tweetMessage.Remove(tweetMessage.Length - index);
                        string TweetData     = "include_entities=true&status=" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + strpostAuthenticityToken;
                        string res_PostTweet = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), TweetData, "https://api.twitter.com/receiver.html", strpostAuthenticityToken, "XMLHttpRequest", "true", "");

                        status = "posted";
                    }
                    else
                    {
                        string TweetData     = "include_entities=true&status=" + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + strpostAuthenticityToken;
                        string res_PostTweet = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), TweetData, "https://api.twitter.com/receiver.html", strpostAuthenticityToken, "XMLHttpRequest", "true", "");

                        status = "posted";
                    }
                }
                else
                {
                    status = "Tweet Message Is Empty !";
                }
            }
            catch (Exception ex)
            {
                status = "not posted";
                //Log("Method>>Tweet  --- class>>Tweeter.cs : Tweet Exception " + ex.Message);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() -- Tweet() --> " + ex.Message, Globals.Path_FollowerErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() -- Tweet()  --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
Example #8
0
        public void Reply(ref Globussoft.GlobusHttpHelper globusHttpHelper, string postAuthenticityToken, string tweetID, string tweetUserName, string screenName, string tweetMessage, string userName)
        {
            try
            {
                if (userName == UserName)
                {
                    string strpostAuthenticityToken = string.Empty;

                    string get_twitter_first = globusHttpHelper.getHtmlfromUrlIP(new Uri("https://twitter.com/"), IPAddress, IPPort, IPUsername, IPpassword, string.Empty, string.Empty);

                    if (!string.IsNullOrEmpty(get_twitter_first) && !string.IsNullOrWhiteSpace(get_twitter_first))
                    {
                        strpostAuthenticityToken = PostAuthenticityToken(get_twitter_first, "postAuthenticityToken");
                    }
                    //Reply
                    //string TweetId = tweetID;// "197682704844734464";
                    //string ReTweetData = "post_authenticity_token=" + postAuthenticityToken;
                    //string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json";
                    //string a6 = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", "");
                    if (!string.IsNullOrEmpty(tweetMessage) && !string.IsNullOrWhiteSpace(tweetMessage))
                    {
                        string TweetId        = tweetID;                                                                                                                                                                                                       //"197551187803906048";
                        string ReplyData      = "in_reply_to_status_id=" + TweetId + "&include_entities=true&status=" + screenName + " " + tweetUserName + " " + HttpUtility.UrlEncode(tweetMessage) + "&post_authenticity_token=" + strpostAuthenticityToken; //"in_reply_to_status_id=" + TweetId + "&include_entities=true&status=%40" + "screenname to reply to" + "+" + tweetMessage + "&post_authenticity_token=" + postAuthenticityToken;
                        string res_Post_Reply = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/statuses/update.json"), ReplyData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", "");

                        //status = "posted";
                        Log("[ " + DateTime.Now + " ] => [ Message Posted Sucessfully Where Status Id = " + tweetID + " With User Name : " + userName + " ]");

                        obj_clsDB_ReplyInterface.DeleteRecordsAfterReplyFromtb_ReplyCampaign(StringEncoderDecoder.Encode(tweetID), StringEncoderDecoder.Encode(userName));
                    }
                    else
                    {
                        Log("[ " + DateTime.Now + " ] => [ Message Couldn't Post  Sucessfully .Since Message Is Empty Where Status Id = " + tweetID + " With User Name : " + userName + " ]");
                    }
                }
            }
            catch (Exception ex)
            {
                //status = "not posted";
                Log("[ " + DateTime.Now + " ] => [ Method>>  Reply  --- class>>  Tweeter.cs : Reply Exception With User Name : " + UserName + "    " + ex.Message + " ]");
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply() --> " + ex.Message, Globals.Path_TweetingErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Reply() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
Example #9
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);
            }
        }
Example #10
0
        public void FollowUsingProfileID(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toFollow, out string status)
        {
            try
            {
                string FollowingData = string.Empty;
                if (NumberHelper.ValidateNumber(user_id_toFollow))
                {
                    FollowingData = "user_id=" + user_id_toFollow + "&post_authenticity_token=" + postAuthenticityToken + "";
                }
                else
                {
                    FollowingData = "screen_name=" + user_id_toFollow + "&post_authenticity_token=" + postAuthenticityToken + "";
                }
                string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://api.twitter.com/1/friendships/create.json"), FollowingData, "https://api.twitter.com/receiver.html", string.Empty, "XMLHttpRequest", "true", "https://api.twitter.com");

                status = "followed";
            }
            catch (Exception ex)
            {
                status = "not followed";
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_FollowerErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> FollowUsingProfileID() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
Example #11
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);
        }
Example #12
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);
                }
            }
        }
Example #13
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);
            }
        }
Example #14
0
        public void SendDirectMessage(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string user_id_toFollow, string msgBodyCompose, string EmailId, out string status)
        {
            try
            {
                string data_user_id    = string.Empty;
                string PostData        = string.Empty;
                string Last_message_Id = string.Empty;
                if (user_id_toFollow.Contains(":"))
                {
                    data_user_id = user_id_toFollow.Split(':')[0];
                }
                else
                {
                    data_user_id = user_id_toFollow;
                }
                // msgBodyCompose = msgBodyCompose.Replace(" ", "+").Trim();
                msgBodyCompose = msgBodyCompose.Trim();
                if (!string.IsNullOrEmpty(user_id_toFollow))
                {
                    PostData = "authenticity_token=" + postAuthenticityToken + "&lastMsgId=" + Last_message_Id + "&screen_name=" + data_user_id + "&scribeContext%5Bcomponent%5D=dm_existing_conversation_dialog&text=" + Uri.EscapeDataString(msgBodyCompose) + "&tweetboxId=";

                    //PostData = "authenticity_token=" + postAuthenticityToken + "&user_id=" + data_user_id;
                    string res_PostFollow = globusHttpHelper.postFormData(new Uri("https://twitter.com/i/direct_messages/new"), PostData, "https://twitter.com/" + user_id_toFollow, string.Empty, "XMLHttpRequest", "true", "");

                    try
                    {
                        string direct_message_id = string.Empty;
                        try
                        {
                            direct_message_id = Utils.getBetween(res_PostFollow, "data-message-id=\\\"", "\\\""); // data-message-id=\"611051888205697024\"
                        }
                        catch {};
                        string username = string.Empty;
                        try
                        {
                            username = Utils.getBetween(res_PostFollow, "href=\\\"\\/", "\\\"");
                        }
                        catch {};

                        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");
                        }
                        if (res_PostFollow.Contains("DirectMessage--sent"))
                        {
                            try
                            {
                                string Insertquery = "insert into tb_DirectMessageDetails(Username,FollowerId,Message) values('" + EmailId + "','" + data_user_id + "','" + msgBodyCompose + "')";
                                DataBaseHandler.InsertQuery(Insertquery, "tb_DirectMessageDetails");
                            }
                            catch { };
                        }
                    }
                    catch (Exception ex)
                    {
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> SendDirectMessage() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_FollowerErroLog);
                        Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> SendDirectMessage() -->insertingdataintodatabase--> " + ex.Message, Globals.Path_TwtErrorLogs);
                    }

                    status = "Message send";
                }
                else
                {
                    status = "Message not send";
                    Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> SendDirectMessage()(User ID is null) ", Globals.Path_FollowerErroLog);
                }
            }
            catch (Exception ex)
            {
                status = "Message not send";
                //Log("Method>>  FollowUsingProfileID  --- class>>  Follower.cs : Follow Exception " + ex.Message);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> SendDirectMessage() --> " + ex.Message, Globals.Path_FollowerErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> SendDirectMessage() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }