Пример #1
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);
        }