예제 #1
0
        public string Login()
        {
            Log("[ " + DateTime.Now + " ] => [ Logging in with Account : " + Username + " ]");
            string Status = "Failed";

            try
            {
                string firstUrl = "https://api.instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes";

                //https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes

                string           secondURL     = "https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes";
                string           res_secondURL = string.Empty;
                ChilkatHttpHelpr objchilkat    = new ChilkatHttpHelpr();
                if (!string.IsNullOrEmpty(proxyAddress) && !string.IsNullOrEmpty(proxyPort))
                {
                    try
                    {
                        //res_secondURL = httpHelper.getHtmlfromUrlProxy(new Uri(secondURL), proxyAddress, int.Parse(proxyPort), proxyUsername, proxyPassword);
                        res_secondURL = objchilkat.GetHtmlProxy(secondURL, proxyAddress, proxyPort, proxyUsername, proxyPassword);
                    }
                    catch { };
                }
                else
                {
                    res_secondURL = httpHelper.getHtmlfromUrl(new Uri(secondURL), "");
                }


                //string authlogin = "******";
                //string res_nextUrl1 = httpHelper.getHtmlfromUrl(new Uri(authlogin), "");
                string nextUrl     = string.Empty;
                string res_nextUrl = string.Empty;

                if (!string.IsNullOrEmpty(res_secondURL))
                {
                    nextUrl = "https://instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize/%3Fclient_id%3D9d836570317f4c18bca0db6d2ac38e29%26redirect_uri%3Dhttp%3A//websta.me/%26response_type%3Dcode%26scope%3Dcomments%2Brelationships%2Blikes";

                    res_nextUrl = httpHelper.getHtmlfromUrl(new Uri(nextUrl), "");//postFormDataProxy
                }
                else
                {
                    Log("[ " + DateTime.Now + " ] => [ Logged in Failed with Account :" + Username + " ]");
                    Status        = "Failed";
                    this.LoggedIn = false;
                }

                //string nextUrl = "https://instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize/%3Fclient_id%3D9d836570317f4c18bca0db6d2ac38e29%26redirect_uri%3Dhttp%3A//websta.me/%26response_type%3Dcode%26scope%3Dcomments%2Brelationships%2Blikes";

                //string res_nextUrl = httpHelper.getHtmlfromUrl(new Uri(nextUrl), "");//postFormDataProxy



                //int FirstPointToken_nextUrl1 = res_nextUrl.IndexOf("authorize");
                //string FirstTokenSubString_nextUrl1 = res_nextUrl.Substring(FirstPointToken_nextUrl1);
                //int SecondPointToken_nextUrl1 = FirstTokenSubString_nextUrl1.IndexOf("%");
                //this.Token = FirstTokenSubString_nextUrl1.Substring(0, SecondPointToken_nextUrl1).Replace("Authorize", string.Empty).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("'", string.Empty).Trim();



                try
                {
                    int    FirstPointToken_nextUrl     = res_nextUrl.IndexOf("csrfmiddlewaretoken");//csrfmiddlewaretoken
                    string FirstTokenSubString_nextUrl = res_nextUrl.Substring(FirstPointToken_nextUrl);
                    int    SecondPointToken_nextUrl    = FirstTokenSubString_nextUrl.IndexOf("/>");
                    this.Token = FirstTokenSubString_nextUrl.Substring(0, SecondPointToken_nextUrl).Replace("csrfmiddlewaretoken", string.Empty).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("'", string.Empty).Trim();
                }
                catch { };


                string login = "******";
                //string authlogin=  "******";

                //string postauthorize = "csrfmiddlewaretoken=" + this.Token + "&allow=Authorize";
                //http://websta.me/?code=90786edc0a4844b79a3d9289d27360d5


                string postdata_Login = "******" + this.Token + "&username="******"&password="******"";

                string res_postdata_Login = httpHelper.postFormData(new Uri(login), postdata_Login, login, "");



                string autho = "https://instagram.com/oauth/authorize/?scope=comments+likes+relationships&redirect_uri=http%3A%2F%2Fwww.gramfeed.com%2Foauth%2Fcallback%3Fpage%3D&response_type=code&client_id=b59fbe4563944b6c88cced13495c0f49";

                if (res_postdata_Login.Contains("Please enter a correct username and password"))
                {
                    Status        = "Failed";
                    this.LoggedIn = false;
                }
                else if (res_postdata_Login.Contains("requesting access to your Instagram account") || postdata_Login.Contains("is requesting to do the following"))
                {
                    Status = "AccessIssue";
                }
                else if (res_postdata_Login.Contains("logout") || postdata_Login.Contains("LOG OUT"))
                {
                    Log("[ " + DateTime.Now + " ] => [ Logged in with Account :" + Username + " ]");
                    Status        = "Success";
                    this.LoggedIn = true;
                }

                //nameval.Clear();
                return(Status);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
예제 #2
0
        public string MyLoginForUnfollow(ref GlobDramProHttpHelper _GlobusHttpHelper, string url, string commentPostData, string referrer)
        {
            Log("[ " + DateTime.Now + " ] => [ Logging in with Account : " + Username + " ]");
            string Status = string.Empty;

            try
            {
                string firstUrl = "https://api.instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes";

                //https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes

                string secondURL = "https://instagram.com/oauth/authorize/?client_id=9d836570317f4c18bca0db6d2ac38e29&redirect_uri=http://websta.me/&response_type=code&scope=comments+relationships+likes";

                string res_secondURL = string.Empty;

                if (!string.IsNullOrEmpty(proxyAddress) && !string.IsNullOrEmpty(proxyPort))
                {
                    try
                    {
                        res_secondURL = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(secondURL), proxyAddress, Convert.ToInt32(proxyPort), proxyUsername, proxyPassword);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    try
                    {
                        res_secondURL = _GlobusHttpHelper.getHtmlfromUrlProxy(new Uri(secondURL), "", 80, "", "");
                    }
                    catch { }
                }

                string nextUrl     = "https://instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize/%3Fclient_id%3D9d836570317f4c18bca0db6d2ac38e29%26redirect_uri%3Dhttp%3A//websta.me/%26response_type%3Dcode%26scope%3Dcomments%2Brelationships%2Blikes";
                string res_nextUrl = _GlobusHttpHelper.getHtmlfromUrl(new Uri("http://websta.me/login"), "");


                //Get Token Number of Id
                int    FirstPointToken_nextUrl     = res_nextUrl.IndexOf("csrfmiddlewaretoken");
                string FirstTokenSubString_nextUrl = res_nextUrl.Substring(FirstPointToken_nextUrl);
                int    SecondPointToken_nextUrl    = FirstTokenSubString_nextUrl.IndexOf("/>");
                this.Token = FirstTokenSubString_nextUrl.Substring(0, SecondPointToken_nextUrl).Replace("csrfmiddlewaretoken", string.Empty).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("'", string.Empty).Trim();



                string login          = "******";
                string postdata_Login = "******" + this.Token + "&username="******"&password="******"";

                string res_postdata_Login = _GlobusHttpHelper.postFormData(new Uri(login), postdata_Login, login, "");

                if (res_postdata_Login.Contains("Please enter a correct username and password"))
                {
                    //Status = "Failed";
                    this.LoggedIn = false;
                }
                else if (res_postdata_Login.Contains("requesting access to your Instagram account") || postdata_Login.Contains("is requesting to do the following"))
                {
                    //Status = "AccessIssue";
                }
                else if (res_postdata_Login.Contains("logout") || postdata_Login.Contains("LOG OUT"))
                {
                    //Status = "Success";
                    string zone = string.Empty;
                    if (res_postdata_Login.Contains("data('userid'") && res_postdata_Login.Contains(")"))
                    {
                        try
                        {
                            zone = ScrapUserName.getBetween(res_postdata_Login, "data('userid'", ")");
                            if (!string.IsNullOrEmpty(zone))
                            {
                                try
                                {
                                    int start = zone.IndexOf("'");
                                    int end   = zone.LastIndexOf("'");
                                    Status = zone.Substring(start + 1, end - start - 1);
                                }
                                catch { }
                            }
                        }
                        catch { }
                    }
                    Log("[ " + DateTime.Now + " ] => [ Logged in with Account :" + Username + " ]");
                    this.LoggedIn = true;
                }

                //nameval.Clear();
                return(Status);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }