Exemplo n.º 1
0
        /// <summary>
        /// Вход в аккаунт
        /// </summary>
        /// <returns></returns>
        public async Task SignIn()
        {
            var delay       = RequestDelay.FromSeconds(2, 2);
            var relatedPath = Environment.CurrentDirectory + PathContract.pathAccount + userSession.UserName + PathContract.stateFile;

            try
            {
                if (File.Exists(relatedPath))
                {
                    Console.WriteLine("Loading state from file");
                    using (var fs = File.OpenRead(relatedPath))
                    {
                        InstaApi.LoadStateDataFromStream(fs);
                    }
                }
                else
                {
                    var currentUser = await InstaApi.LoginAsync();

                    if (currentUser.Succeeded)
                    {
                        SaveSession();
                    }
                    else
                    {
                        await GetChallenge();

                        SaveSession();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            LoadSession();
            if (!InstaApi.IsUserAuthenticated)
            {
                var currentUser = await InstaApi.LoginAsync();

                if (currentUser.Succeeded)
                {
                    SaveSession();
                }
                else
                {
                    await GetChallenge();

                    SaveSession();
                    LoadSession();
                }
            }
            else
            {
                Console.WriteLine("Session loaded!");
            }
        }
Exemplo n.º 2
0
        async Task Login()
        {
            api = InstaApiBuilder.CreateBuilder()
                  .SetUser(user)
                  .UseLogger(new DebugLogger(LogLevel.Exceptions))
                  .Build();

            var loginRequest = await api.LoginAsync();

            if (loginRequest.Succeeded)
            {
                IResult <InstaCurrentUser> result = await api.GetCurrentUserAsync();

                var    names      = result.Value.FullName.Split(' ');
                string firstname  = names[0];
                string secondName = secondName = names[1];
                string mail       = result.Value.Email;
                string telNumber  = result.Value.PhoneNumber;
                byte[] image;
                using (WebClient client = new WebClient())
                {
                    client.DownloadFile(new Uri(result.Value.HdProfilePicture.Uri), User.filename);
                }
                using (System.IO.FileStream fs = new System.IO.FileStream(User.filename, System.IO.FileMode.OpenOrCreate))
                {
                    image = new byte[fs.Length];
                    fs.Read(image, 0, image.Length);
                }

                string about = result.Value.FullName + "\n" + result.Value.Gender + "\n" + result.Value.UserName + "\n" + result.Value.CountryCode;
                tmp = new User(firstname, secondName, mail, telNumber, about, image);
            }
        }
Exemplo n.º 3
0
        public async Task InstagramLogin()
        {
            if (!api.IsUserAuthenticated)
            {
                await api.SendRequestsBeforeLoginAsync();

                var logResult = await api.LoginAsync();

                if (logResult.Succeeded)
                {
                    Console.WriteLine("----- LOGIN RIUSCITO -----");
                    await api.SendRequestsAfterLoginAsync();

                    await App.Current.MainPage.DisplayAlert("LOGIN RIUSCITO", "goditi l'app", "OK");
                }
                else
                {
                    Console.WriteLine("------ LOGIN FALLITO ------");
                    await App.Current.MainPage.DisplayAlert("LOGIN FALLITO", "ricontrolla i dati", "OK");
                }
            }
            else
            {
                Console.WriteLine("LOGIN GIA' EFFETTUATO", "goditi l'app", "OK");
            }
        }
Exemplo n.º 4
0
        private async void Login()
        {
            try
            {
                // создаем  обьект, через который происходит основная работа
                api = InstaApiBuilder.CreateBuilder()
                      .SetUser(user)
                      .UseLogger(new DebugLogger(LogLevel.Exceptions))
                      .SetRequestDelay(RequestDelay.FromSeconds(7, 9))
                      .Build();
                var loginRequest = await api.LoginAsync();

                if (loginRequest.Succeeded)
                {
                    logBox.Items.Add("Logged in succes, press Start");
                    btn_start.Enabled    = true;
                    btn_unfollow.Enabled = true;
                }
                else
                {
                    logBox.Items.Add("Logged in failed! " + loginRequest.Info.Message);
                }
            }
            catch (Exception ex) {
                logger.CloseLog();
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 5
0
        public async Task <int> RemoveSubscribersAsync(int count)
        {
            if (!_api.IsUserAuthenticated)
            {
                await _api.LoginAsync();
            }

            var type = _api.GetType();

            type.GetProperty("IsUserAuthenticated")?.SetValue(_api, true);

            var currentUser = await _api.GetCurrentUserAsync();

            var followings = await _api.GetUserFollowingAsync(currentUser.Value.UserName, PaginationParameters.MaxPagesToLoad(20));

            var iteration = 0;

            foreach (var following in followings.Value)
            {
                if (iteration == count)
                {
                    return(iteration);
                }

                await Task.Delay(TimeSpan.FromMilliseconds(new Random().Next(20, 200)));

                var unFollowResult = await _api.UnFollowUserAsync(following.Pk);

                Console.WriteLine($"{(unFollowResult.Succeeded ? $"Success unfollowed {following.UserName}" : unFollowResult.Info.Message)}");

                iteration++;
            }

            return(iteration);
        }
        public async static Task Login(string username, string password)
        {
            var userSession = new UserSessionData
            {
                UserName = username,
                Password = password
            };

            _instaApi = InstaApiBuilder.CreateBuilder()
                        .SetUser(userSession)
                        .UseLogger(new DebugLogger(LogLevel.All)) // use logger for requests and debug messages
                        .SetRequestDelay(TimeSpan.FromSeconds(0))
                        .Build();

            if (!_instaApi.IsUserAuthenticated)
            {
                // login
                Console.WriteLine($"Logging in as {userSession.UserName}");
                var logInResult = await _instaApi.LoginAsync();

                if (!logInResult.Succeeded)
                {
                    Console.WriteLine($"Unable to login: {logInResult.Info.Message}");
                }
            }
        }
Exemplo n.º 7
0
        private async void MetroButton1_Click(object sender, EventArgs e)
        {
            if (api == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(tBox_Code.Text))
            {
                MessageBox.Show("Please type your two factor code and then press Auth button.", "ERR");
                return;
            }
            //try
            //{
            // send two factor code
            var twoFactorLogin = await api.TwoFactorLoginAsync(tBox_Code.Text);

            if (twoFactorLogin.Succeeded)
            {
                var result = await api.LoginAsync();

                if (result.Succeeded)
                {
                    Close();
                }
            }
            else
            {
                MessageBox.Show(twoFactorLogin.Info.Message, "ERR");
            }
            //}
            //catch (Exception ex) { MessageBox.Show("TwoFactorVerifyCodeButton_Click " + ex.Message); }
            //Close();
        }
Exemplo n.º 8
0
Arquivo: Form1.cs Projeto: IVT2/Client
        public static async void Subs(string userExp, string userName, string password)
        {
            user          = new UserSessionData();
            user.UserName = userName;
            user.Password = password;

            api = InstaApiBuilder.CreateBuilder()
                  .SetUser(user)
                  .UseLogger(new DebugLogger(LogLevel.Exceptions))
                  //.SetRequestDelay(TimeSpan.FromSeconds(1))
                  .Build();
            var loginRequest = await api.LoginAsync();

            IResult <InstaUser> userSearch = await api.GetUserAsync(userExp);

            IResult <InstaUserShortList> followers = await api.GetUserFollowersAsync(userSearch.Value.UserName, PaginationParameters.MaxPagesToLoad(5));

            var followlist       = followers.Value;
            int count_followlist = followlist.ToArray().Length;

            for (int i = 0; i < count_followlist; i++)
            {
                var res = await api.FollowUserAsync(followlist[i].Pk);

                string result = res.Succeeded.ToString();
            }
        }
Exemplo n.º 9
0
Arquivo: Form1.cs Projeto: IVT2/Client
        public static async void Like(string userExp, string userName, string password)
        {
            user          = new UserSessionData();
            user.UserName = userName;
            user.Password = password;

            api = InstaApiBuilder.CreateBuilder()
                  .SetUser(user)
                  .UseLogger(new DebugLogger(LogLevel.Exceptions))
                  //.SetRequestDelay(TimeSpan.FromSeconds(1))
                  .Build();
            var loginRequest = await api.LoginAsync();

            IResult <InstaUser> userSearch = await api.GetUserAsync(userExp);

            IResult <InstaMediaList> media = await api.GetUserMediaAsync(userExp, PaginationParameters.MaxPagesToLoad(5));

            var mediaList       = media.Value;
            int count_mediaList = mediaList.ToArray().Length;

            for (int i = 0; i < count_mediaList; i++)
            {
                var res = await api.LikeMediaAsync(mediaList[i].InstaIdentifier);

                string result = res.Succeeded.ToString();
            }
        }
        public async Task <IResult <InstaLoginResult> > Login()
        {
            var clientHandler = new HttpClientHandler();

            clientHandler.Proxy = new WebProxy(ip, port)
            {
                Credentials = new NetworkCredential(_proxyUserName, _proxyPassword)
            };

            _user.UserName  = _username;
            _user.Password  = _password;
            _user.CsrfToken = "LQKVEEt9LEtmZz36IYa4vJzLxLGjUv3G";
            _user.RankToken = "8286475698_8afad275-4fca-49e6-a5e0-3b2bbfe6e9f2";

            var delay = RequestDelay.FromSeconds(1, 1); //TODO: numeric_up_down delay

            _api = InstaApiBuilder.CreateBuilder()
                   .SetUser(_user)
                   .UseLogger(new DebugLogger(LogLevel.All))
                   .UseHttpClientHandler(clientHandler)
                   .SetRequestDelay(delay)
                   .Build();


            var loginRequest = await _api.LoginAsync();

            return(loginRequest);
            //var re = (await _api.ResetChallenge()).Value.StepData.Email = "*****@*****.**";

            //var re2 = await _api.ResetChallenge();

            //var verify_result = await _api.ChooseVerifyMethod(1);
        }
Exemplo n.º 11
0
        private static async Task <bool> IsUserSessionStored()
        {
            try
            {
                if (InstaApi != null)
                {
                    InstaApi = null;
                    return(false);
                }
                var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("UserSession.dat", CreationCollisionOption.OpenIfExists);

                var r = await FileIO.ReadTextAsync(file);

                string User = "******"; string Pass = "******";
                //LoadUserInfo(out User, out Pass);
                //if (User == null || Pass == null) return false;
                InstaApi = InstaApiBuilder.CreateBuilder()
                           .SetUser(new UserSessionData {
                    UserName = User, Password = Pass
                })
                           .UseLogger(new DebugLogger(LogLevel.Exceptions))
                           .Build();
                InstaApi.LoadStateDataFromStream(r);
                if (!InstaApi.IsUserAuthenticated)
                {
                    await InstaApi.LoginAsync();
                }
                return(true);
            }
            catch (Exception ex)
            {
                InstaApi = null;
                return(false);
            }
        }
Exemplo n.º 12
0
        private async Task <bool> LoginAsync(string username, string password)
        {
            if (_api != null && _api.IsUserAuthenticated)
            {
                return(true);
            }
            var userSession = new UserSessionData {
                UserName = username, Password = password
            };

            _api = InstaApiBuilder.CreateBuilder()
                   .SetUser(userSession)
                   .UseLogger(new DebugLogger(LogLevel.Exceptions)).Build();

            var loginRequest = await _api.LoginAsync();

            if (loginRequest.Succeeded)
            {
                Console.WriteLine("Logged in!");
            }
            else
            {
                var errorMsg = loginRequest.Info.Message;
                Console.WriteLine("Error Logging in!" + Environment.NewLine + errorMsg);
                if (errorMsg == "Please wait a few minutes before you try again.")
                {
                    Thread.Sleep(TimeSpan.FromMinutes(5));
                }
            }

            return(loginRequest.Succeeded);
        }
Exemplo n.º 13
0
        public async Task <bool> LoginAsync(string userName, string password)
        {
            instaApi.SetUser(userName, password);

            var loginResponse = await instaApi.LoginAsync();

            return(loginResponse.Succeeded);
        }
Exemplo n.º 14
0
        public async Task TriggerVerifyCode()
        {
            IInstaApi api = await GetApi();

            await api.LoginAsync();

            await api.ChooseVerifyMethod(0);
        }
Exemplo n.º 15
0
        private static IResult <InstaLoginResult> TryLogIn(IInstaApi instaApi)
        {
            Task <IResult <InstaLoginResult> > logInTask = Task.Run(() => instaApi.LoginAsync());

            logInTask.Wait();

            return(logInTask.Result);
        }
Exemplo n.º 16
0
        private async void LoginButton_Click(object sender, EventArgs e)
        {
            Size = NormalSize;
            var userSession = new UserSessionData
            {
                UserName = txtUsername.Text,
                Password = txtPassword.Text
            };

            InstaApi = InstaApiBuilder.CreateBuilder()
                       .SetUser(userSession)
                       .UseLogger(new DebugLogger(LogLevel.Exceptions))
                       .SetRequestDelay(RequestDelay.FromSeconds(0, 1))
                       .Build();
            Text = $"{AppName} Connecting";
            try
            {
                if (File.Exists(StateFile))
                {
                    Debug.WriteLine("Loading state from file");
                    using (var fs = File.OpenRead(StateFile))
                    {
                        InstaApi.LoadStateDataFromStream(fs);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            if (!InstaApi.IsUserAuthenticated)
            {
                var logInResult = await InstaApi.LoginAsync();

                Debug.WriteLine(logInResult.Value);
                if (logInResult.Succeeded)
                {
                    Text = $"{AppName} Connected";
                    // Save session
                    SaveSession();
                }
                else
                {
                    // two factor is required
                    if (logInResult.Value == InstaLoginResult.TwoFactorRequired)
                    {
                        // open a box so user can send two factor code
                        Size = TwoFactorSize;
                    }
                }
            }
            else
            {
                Text = $"{AppName} Connected";
            }
        }
        /// <summary>
        /// Insta Giriş Yapma
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Button_InstaGirisYap_Click(object sender, EventArgs e)
        {
            // Session Başlatma
            var userSession = new UserSessionData
            {
                UserName = textBox_InstaGiris_kadi.Text,
                Password = textBox_InstaGiris_Sifre.Text
            };

            string StateYol = StateFile;

            // dosya var mı kontrol et varsa eğer sil
            if (File.Exists(StateYol))
            {
                File.Delete(StateYol);
            }

            // Oturum oluşturma
            InstaApi = InstaApiBuilder.CreateBuilder()
                       .SetUser(userSession)
                       .SetRequestDelay(RequestDelay.FromSeconds(0, 1))
                       .SetSessionHandler(new FileSessionHandler()
            {
                FilePath = StateYol
            })
                       .Build();
            LoadSession();


            // Giriş kontrolü
            if (!InstaApi.IsUserAuthenticated)
            {
                // Başarısız

                // Giriş çıktısı
                var logInResult = await InstaApi.LoginAsync();

                // Başarılı mı?
                if (logInResult.Succeeded)
                {
                    // Bilgi Mesajı
                    BilgiMesaji("basarili", "Giriş yapıldı.", this.Text, true);
                    SaveSession();
                }
                else
                {
                    // Bilgi Mesajı
                    BilgiMesaji("basarili", "Giriş yapılamadı.", this.Text, true);
                }
            }
            else
            {
                // Bilgi Mesajı
                BilgiMesaji("basarili", "Giriş yapıldı.", this.Text, true);
                SaveSession();
            }
        }
Exemplo n.º 18
0
        protected void LikeButton_Click1(object sender, EventArgs e)
        {
            string url = UrlText.Text;

            long   id = shortcodeToInstaID(url);
            string Id = id.ToString();

            LikeButton.Text = Id;

            DataTable dt = new DataTable();

            dt = db.Fill("select * from Userstbl ");


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var userSession = new UserSessionData
                {
                    UserName = dt.Rows[i]["Username"].ToString(),
                    Password = dt.Rows[i]["Password"].ToString()
                };


                var delay = RequestDelay.FromSeconds(2, 2);
                ınstagramApi = InstaApiBuilder.CreateBuilder()
                               .SetUser(userSession)
                               .UseLogger(new DebugLogger(LogLevel.Exceptions)) // use logger for requests and debug messages
                               .SetRequestDelay(delay)
                                                                                //.SetDevice(androidDevice);
                               .SetSessionHandler(new FileSessionHandler()
                {
                    FilePath = StateFile
                })
                               .Build();
                var r = Task.Run(() => ınstagramApi.LoginAsync());
                if (r.Result.Succeeded)
                {
                    LikeButton.Text = "Login";
                }


                //    var z = Task.Run(() => ınstagramApi.MediaProcessor.GetMediaIdFromUrlAsync(uri));

                //    string ID = z.Result.Value;

                //string id = "2372503629901614370";

                var x = Task.Run(() => ınstagramApi.MediaProcessor.LikeMediaAsync(Id));

                //if (x.Result.Succeeded)
                //{
                //    LikeButton.Text = "Liked Successfully";
                //}
            }
            //LoadSession();
        }
        private static async Task <(bool, string)> LoginIfUnauthorised(IInstaApi api, IRequestDelay delay)
        {
            delay.Disable();
            var logInResult = await api.LoginAsync();

            delay.Enable();
            return(!logInResult.Succeeded
                ? (false, $"unable to login {logInResult.Info.Message}")
                : (true, String.Empty));
        }
Exemplo n.º 20
0
        public async void rememberLogin()
        {
            try
            {
                if (File.Exists(startupPath2 + "//user.txt") == true && File.Exists(startupPath2 + "//pass.txt") == true)
                {
                    loginStatus.Text = "Logging...";
                    var userSession = new UserSessionData
                    {
                        UserName = File.ReadAllText(startupPath2 + "//user.txt"),
                        Password = File.ReadAllText(startupPath2 + "//pass.txt"),
                    };
                    InstaApi = InstaApiBuilder.CreateBuilder()
                               .SetUser(userSession)
                               .UseLogger(new DebugLogger(LogLevel.All))
                               .Build();

                    var loginResult = await InstaApi.LoginAsync();

                    if (loginResult.Succeeded == true)
                    {
                        loginStatus.ForeColor = Color.DarkGreen;
                        btnLogout.Enabled     = true;
                        loginStatus.Text      = "Succeess";
                    }
                    else if (loginResult.Value.ToString() == "ChallengeRequired")
                    {
                        MessageBox.Show("ChallengeRequired please try to login again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        File.Delete(startupPath2 + "//user.txt");
                        File.Delete(startupPath2 + "//pass.txt");
                        btnLogout.Enabled = false;
                        loginStatus.Text  = "Not Login";
                    }
                    else if (loginResult.Value.ToString() == "Invalid User")
                    {
                        File.Delete(startupPath2 + "//user.txt");
                        File.Delete(startupPath2 + "//pass.txt");
                        MessageBox.Show("Invalid User please try to login again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        btnLogout.Enabled = false;
                        loginStatus.Text  = "Not Login";
                    }
                }

                else
                {
                    loginStatus.Text  = "Not Login";
                    btnLogout.Enabled = false;
                }
            }
            catch
            {
                loginStatus.ForeColor = Color.Red;
                loginStatus.Text      = "Connection Faild";
            }
        }
Exemplo n.º 21
0
        //登录账号
        public static async System.Threading.Tasks.Task InsLoginAsync()
        {
            #region 登录Ins
            Console.WriteLine("登录Ins...");
            var userSession = new UserSessionData
            {
                UserName = "******",
                Password = "******"
            };

            var delay = RequestDelay.FromSeconds(2, 2);
            InstaApi = InstaApiBuilder.CreateBuilder()
                       .SetUser(userSession)
                       .UseLogger(new DebugLogger(LogLevel.All))
                       .SetRequestDelay(delay)
                       .Build();
            const string stateFile = "state.bin";
            try
            {
                if (System.IO.File.Exists(stateFile))
                {
                    Console.WriteLine("从文件加载登录.");
                    using (var fs = System.IO.File.OpenRead(stateFile))
                    {
                        InstaApi.LoadStateDataFromStream(fs);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (!InstaApi.IsUserAuthenticated)
            {
                // login
                Console.WriteLine($"Logging in as {userSession.UserName}");
                delay.Disable();
                var logInResult = await InstaApi.LoginAsync();

                delay.Enable();
                if (!logInResult.Succeeded)
                {
                    Console.WriteLine($"Unable to login: {logInResult.Info.Message}");
                }
            }
            var state = InstaApi.GetStateDataAsStream();
            using (var fileStream = System.IO.File.Create(stateFile))
            {
                state.Seek(0, SeekOrigin.Begin);
                state.CopyTo(fileStream);
            }
            Console.WriteLine("已登录");
            #endregion
        }
Exemplo n.º 22
0
        public static async Task <bool> Login(IInstaApi apiInstance, ITestOutputHelper output)
        {
            var loginResult = await apiInstance.LoginAsync();

            if (!loginResult.Succeeded)
            {
                output.WriteLine($"Can't login: {loginResult.Info.Message}");
                return(false);
            }
            return(true);
        }
Exemplo n.º 23
0
        public static async void UploadPhoto(string path)
        {
            const string stateFile = "state.bin";

            var userSession = new UserSessionData
            {
                UserName = File.ReadAllLines("LoginInfo.txt")[0],
                Password = File.ReadAllLines("LoginInfo.txt")[1]
            };

            Console.WriteLine("Initializing API");

            _instaApi = InstaApiBuilder.CreateBuilder()
                        .SetUser(userSession)
                        .UseLogger(new DebugLogger(LogLevel.Exceptions))
                        .SetRequestDelay(TimeSpan.FromSeconds(2))
                        .Build();

            Console.WriteLine($"Logging into {userSession.UserName}");

            var logInResult = await _instaApi.LoginAsync();

            if (!logInResult.Succeeded)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Login failed => {logInResult.Info.Message}");
                return;
            }
            else
            {
                Console.WriteLine("Login successfull");
            }

            var state = _instaApi.GetStateDataAsStream();

            using (var fileStream = File.Create(stateFile))
            {
                state.Seek(0, SeekOrigin.Begin);
                state.CopyTo(fileStream);
            }

            Console.WriteLine("API initialized succesfully ");

            var upl = new UploadPhoto(_instaApi);

            Console.WriteLine("Press ENTER and type optional caption (leave blank if undesired)");

            string caption = Console.ReadLine();

            Console.WriteLine($"Uploading with caption {caption}");

            await upl.UploadImg(caption, path);
        }
Exemplo n.º 24
0
        private async Task <IInstaApi> OpenApi()
        {
            IInstaApi api = await GetApi();

            IResult <InstaLoginResult> loginResult = await api.LoginAsync();

            if (!loginResult.Succeeded)
            {
                throw new OdkServiceException($"Instagram login failed");
            }

            return(api);
        }
Exemplo n.º 25
0
        public async Task Login()
        {
            var loginRequest = await instaApi.LoginAsync();

            if (loginRequest.Succeeded)
            {
                logger.Write("Success");
            }
            else
            {
                logger.Write(loginRequest.Info.Message);
            }
        }
Exemplo n.º 26
0
        public static async Task <bool> Login(string uname, string pword)
        {
            Err      = "";
            InstaApi = InstaSharper.API.Builder.InstaApiBuilder.CreateBuilder()
                       .SetUser(new UserSessionData()
            {
                UserName = uname, Password = pword
            })
                       .SetRequestDelay(RequestDelay.FromSeconds(1, 2))
                       .Build();
            var loginResult = await InstaApi.LoginAsync();

            //if (loginResult.Info.Message == "Challenge is required")
            //{
            //    var resgv = await InstaApi.GetVerifyStep();

            //    var resvm = await InstaApi.ChooseVerifyMethod(1);

            //    var resvc = await InstaApi.SendVerifyCode("832549");

            //    if (resvc.Succeeded)
            //    {
            //        return true;
            //    }
            //}

            if (loginResult.Succeeded)
            {
                if (InstaApi.IsUserAuthenticated)
                {
                    //var StateData = InstaApi.GetStateDataAsStream();

                    //var accountsFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Accounts");
                    //var instagramFolder = await accountsFolder.GetFolderAsync("Instagram");
                    //var loginsFolder = await instagramFolder.GetFolderAsync("Logins");
                    //var loginFile = await loginsFolder.CreateFileAsync(uname + ".logininfo", CreationCollisionOption.ReplaceExisting);
                    //await FileIO.WriteBytesAsync(loginFile, (StateData as MemoryStream).ToArray());
                    return(true);
                }
                else
                {
                    Err = "خطا در تایید هویت حساب شما لطفا از طریق نرم افزار موبایل یا وبسایت وارد شوید سپس دوباره امتحان کنید";
                    return(false);
                }
            }
            else
            {
                Err = "نام کاربری یا کلمه عبور اشتباه است";
                return(false);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Sign in instagram
        /// </summary>
        /// <returns></returns>
        private async Task Login()
        {
            if (_instaApi.IsUserAuthenticated)
            {
                return;
            }

            var logInResult = await _instaApi.LoginAsync();

            if (!logInResult.Succeeded)
            {
                _logger.LogWarning(logInResult.Info.Message.ToString());
            }
        }
Exemplo n.º 28
0
        public static async Task <bool> MainAsync()
        {
            try
            {
                // create user session data and provide login details.
                var userSession = new UserSessionData
                {
                    UserName = userLogin,
                    Password = userPassword
                };
                var delay = RequestDelay.FromSeconds(2, 2);
                // create new InstaApi instance using Builder
                _instaApi = InstaApiBuilder.CreateBuilder()
                            .SetUser(userSession)
                            .UseLogger(new DebugLogger(LogLevel.Exceptions)) // use logger for requests and debug messages
                            .SetRequestDelay(delay)
                            .Build();
                // authentification.
                if (!_instaApi.IsUserAuthenticated)
                {
                    // login
                    Console.WriteLine($"Logging in as {userSession.UserName}");
                    delay.Disable();
                    var logInResult = await _instaApi.LoginAsync();

                    delay.Enable();
                    if (!logInResult.Succeeded)
                    {
                        Console.WriteLine($"Unable to login: {logInResult.Info.Message}");
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                // perform that if user needs to logged out
                // var logoutResult = Task.Run(() => _instaApi.LogoutAsync()).GetAwaiter().GetResult();
                // if (logoutResult.Succeeded) Console.WriteLine("Logout succeed");
            }
            return(false);
        }
Exemplo n.º 29
0
        private async Task <IResult <InstaLoginResult> > LoginAsync()
        {
            var userSession = new UserSessionData
            {
                UserName = _userName,
                Password = _password
            };

            _instaApi = InstaApiBuilder.CreateBuilder()
                        .SetUser(userSession)
                        .UseLogger(new DebugLogger(LogLevel.All))
                        .Build();

            return(await _instaApi.LoginAsync());
        }
Exemplo n.º 30
0
        /// <summary>
        /// Check if the creds work
        /// </summary>
        /// <returns></returns>
        public static async Task <bool> InstagramLogin()
        {
            if (!api.IsUserAuthenticated)
            {
                // login
                Console.WriteLine($"Logging in as {userSession.UserName}");
                var logInResult = await api.LoginAsync();

                if (!logInResult.Succeeded)
                {
                    MessageBox.Show($"Unable to login: {logInResult.Info.Message}");
                    return(false);
                }
            }
            return(true);
        }