Ejemplo n.º 1
0
        public static async Task <bool> Initialization(Stream data, string uname = "Queen", string pword = "Saigon")
        {
            Err      = "";
            InstaApi = InstaSharper.API.Builder.InstaApiBuilder.CreateBuilder()
                       .SetUser(new UserSessionData()
            {
                UserName = uname, Password = pword
            })
                       .SetRequestDelay(RequestDelay.FromSeconds(1, 2))
                       .Build();
            InstaApi.LoadStateDataFromStream(data);
            if (InstaApi.IsUserAuthenticated)
            {
                var Result = await InstaApi.GetCurrentUserAsync();

                if (Result.Succeeded)
                {
                    Initialized = true;
                    Userid      = Result.Value.Pk;
                    Username    = Result.Value.UserName;

                    return(true);
                }
                else
                {
                    Err = "خطا در تایید هویت حساب لطفا دوباره سعی کنید یا دوباره وارد شوید";
                    return(false);
                }
            }
            else
            {
                Err = "خطا در تایید هویت حساب لطفا دوباره سعی کنید یا دوباره وارد شوید";
                return(false);
            }
        }
        public static async Task <string> UploadVideo(InstagramData instagramData)
        {
            var userSession = new UserSessionData
            {
                UserName = instagramData.Username,
                Password = instagramData.Password
            };

            var delay = RequestDelay.FromSeconds(2, 2);

            var api = GetApi(delay, userSession);

            loadSessionData(api);
            var(successLogin, possibleMessage) = await LoginIfUnauthorised(api, delay);

            if (!successLogin)
            {
                return(possibleMessage);
            }

            UpdateLoginState(api);

            var videoUpload = CreateNewVideoUpload(instagramData.VideoPath, instagramData.ImagePath);
            var result      = await api.MediaProcessor.UploadVideoAsync(videoUpload, instagramData.Comments);

            return(result.Succeeded
                ? $"Uploaded Successfully, Media created {result.Info.Message}"
                : $"Unable to upload video: {result.Info.Message}");
        }
Ejemplo n.º 3
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());
            }
        }
Ejemplo n.º 4
0
        public void DelaySameValueTest()
        {
            var s     = 5;
            var delay = RequestDelay.FromSeconds(s, s);

            Assert.True(delay.Value.Seconds == s);
        }
Ejemplo n.º 5
0
        public InstagramBot()
        {
            dynamic credentialJson = JsonConvert.DeserializeObject(File.ReadAllText("Credentials.json"));

            _userSessionData = new UserSessionData
            {
                UserName = credentialJson["INSTAGRAM_USER"],
                Password = credentialJson["INSTAGRAM_PASSWORD"]
            };

            var delay = RequestDelay.FromSeconds(2, 2);

            _instaApi = InstaApiBuilder.CreateBuilder()
                        .SetUser(_userSessionData)
                        .UseLogger(new DebugLogger(LogLevel.Exceptions))
                        .SetRequestDelay(delay)
                        .Build();

            try
            {
                if (File.Exists(stateFile))
                {
                    using (var fs = File.OpenRead(stateFile))
                    {
                        _instaApi.LoadStateDataFromStream(fs);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 6
0
        public async Task DoShow()
        {
            var result = await InstaApi.GetCurrentUserAsync();

            if (!result.Succeeded)
            {
                Console.WriteLine($"Unable to get current user using current API instance: {result.Info}");
                return;
            }
            Console.WriteLine($"Got current user: {result.Value.UserName} using existing API instance");
            var stream = InstaApi.GetStateDataAsStream();
            //// for .net core you should use this method:
            // var json = _instaApi.GetStateDataAsString();
            var anotherInstance = InstaApiBuilder.CreateBuilder()
                                  .SetUser(UserSessionData.Empty)
                                  .SetRequestDelay(RequestDelay.FromSeconds(2, 2))
                                  .Build();

            anotherInstance.LoadStateDataFromStream(stream);
            //// for .net core you should use this method:
            // anotherInstance.LoadStateDataFromString(json);
            var anotherResult = await anotherInstance.GetCurrentUserAsync();

            if (!anotherResult.Succeeded)
            {
                Console.WriteLine($"Unable to get current user using current API instance: {result.Info}");
                return;
            }
            Console.WriteLine(
                $"Got current user: {anotherResult.Value.UserName} using new API instance without re-login");
        }
Ejemplo n.º 7
0
        public void DelayDisableTest()
        {
            var delay = RequestDelay.FromSeconds(1, 2);

            delay.Disable();
            Assert.False(delay.Exist);
        }
Ejemplo n.º 8
0
        public async Task <IInstaApi> Create()
        {
            if (_api != null)
            {
                return(_api);
            }

            var api = InstaApiBuilder.CreateBuilder()
                      .SetUser(new UserSessionData
            {
                UserName = _config.Username,
                Password = _config.Password
            })
                      //.UseLogger(_logger)
                      .SetRequestDelay(RequestDelay.FromSeconds(2, 2))
                      .Build();

            var status = await api.LoginAsync();

            if (!status.Succeeded)
            {
                throw new InstaException($"Login failed with username '{_config.Username}'.");
            }

            _api = api;
            return(_api);
        }
        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);
        }
Ejemplo n.º 10
0
        public void DelayDisableValueTest()
        {
            var s     = 5;
            var delay = RequestDelay.FromSeconds(s, s);

            delay.Disable();
            Assert.Equal(TimeSpan.Zero, delay.Value);
        }
Ejemplo n.º 11
0
 internal Account()
 {
     _api = InstaApiBuilder.CreateBuilder()
            .SetUser(UserSessionData.Empty)
            .SetRequestDelay(RequestDelay.FromSeconds(0, 1))
            .Build();
     _api.SetApiVersion(InstagramApiSharp.Enums.InstaApiVersionType.Version126);
 }
Ejemplo n.º 12
0
 private IInstaApi CreateInstaInstance(UserSessionData userSessionData)
 {
     return(InstaApiBuilder.CreateBuilder()
            .SetUser(userSessionData)
            .UseLogger(new DebugLogger(LogLevel.All))
            .SetRequestDelay(RequestDelay.FromSeconds(min: 0, max: 1))
            .Build());
 }
Ejemplo n.º 13
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!");
            }
        }
Ejemplo n.º 14
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";
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 ///     Set delay between requests. Useful when API supposed to be used for mass-bombing.
 /// </summary>
 /// <param name="delay">Timespan delay</param>
 /// <returns>
 ///     API Builder
 /// </returns>
 public IInstaApiBuilder SetRequestDelay(IRequestDelay delay)
 {
     if (delay == null)
     {
         delay = RequestDelay.Empty();
     }
     _delay = delay;
     return(this);
 }
        /// <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();
            }
        }
Ejemplo n.º 17
0
        public static IInstaApi GetDefaultInstaApiInstance(UserSessionData user)
        {
            var apiInstance = InstaApiBuilder.CreateBuilder()
                              .SetUser(user)
                              .SetRequestDelay(RequestDelay.FromSeconds(5, 5))
                              .Build();

            return(apiInstance);
        }
Ejemplo n.º 18
0
 /// <summary>
 ///     Builds the complete arguments for invoking newman
 /// </summary>
 /// <param name="args">The argument builder.</param>
 public void Build(ProcessArgumentBuilder args)
 {
     if (EnvironmentFile != null)
     {
         args.AppendSwitchQuoted(ArgumentNames.Environment, EnvironmentFile.FullPath);
     }
     if (GlobalVariablesFile != null)
     {
         args.AppendSwitchQuoted(ArgumentNames.Globals, GlobalVariablesFile.FullPath);
     }
     if (!string.IsNullOrWhiteSpace(Folder))
     {
         args.AppendSwitchQuoted(ArgumentNames.Folder, Folder);
     }
     if (ExportEnvironmentPath != null)
     {
         args.AppendSwitchQuoted(ArgumentNames.ExportEnvironment, ExportEnvironmentPath.FullPath);
     }
     if (ExportGlobalsPath != null)
     {
         args.AppendSwitchQuoted(ArgumentNames.ExportGlobals, ExportGlobalsPath.FullPath);
     }
     if (ExportCollectionPath != null)
     {
         args.AppendSwitchQuoted(ArgumentNames.ExportCollection, ExportCollectionPath.FullPath);
     }
     if (RequestTimeout != default(int))
     {
         args.AppendSwitch(ArgumentNames.RequestTimeout, RequestTimeout.ToString());
     }
     if (DisableStrictSSL)
     {
         args.Append(ArgumentNames.Insecure);
     }
     if (IgnoreRedirects)
     {
         args.Append(ArgumentNames.IgnoreRedirects);
     }
     if (RequestDelay != default(int))
     {
         args.AppendSwitch(ArgumentNames.RequestDelay, RequestDelay.ToString());
     }
     if (ExitOnFirstFailure)
     {
         args.Append(ArgumentNames.Bail);
     }
     if (Reporters.Any())
     {
         args.AppendSwitch(ArgumentNames.Reporters,
                           string.Join(",", Reporters.Keys.Select(k => k.Trim())));
         foreach (var reporter in Reporters)
         {
             reporter.Value?.RenderOptions(args);
         }
     }
 }
Ejemplo n.º 19
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();
        }
Ejemplo n.º 20
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
        }
Ejemplo n.º 21
0
 private void CreateInstaApi(string userName, string password)
 {
     _instaApi = InstaApiBuilder.CreateBuilder()
                 .SetRequestDelay(RequestDelay.FromSeconds(1, 2))
                 .SetUser(new UserSessionData
     {
         UserName = userName,
         Password = password
     })
                 .Build();
 }
Ejemplo n.º 22
0
        private async void LoadAccountHTTPSession_posting()
        {
            InitalizeProxy(PostingAccount, ref PROXY_Posting);
            AccountMangerRow = Login.DT_AccountManager.Select("UserName_Email='" + PostingAccount + "'").FirstOrDefault();

            string stateFile   = PostingAccount.GetHashCode().ToString();
            var    userSession = new UserSessionData
            {
                UserName = PostingAccount,
                Password = AccountMangerRow["Password"].ToString()
            };
            var httpClientHandler = new HttpClientHandler {
                Proxy = PROXY_Posting
            };


            var delay = RequestDelay.FromSeconds(2, 2);

            PinApi_posing = PinApiBuilder.CreateBuilder().SetUser(userSession)
                            .UseLogger(new DebugLogger(LogLevel.All)) // use logger for requests and debug messages
                            .UseHttpClientHandler(httpClientHandler)
                            .SetRequestDelay(delay)
                            .Build();
            try
            {
                if (File.Exists(stateFile))
                {
                    using (var fs = File.OpenRead(stateFile))
                    {
                        PinApi_posing.LoadStateDataFromStream(fs);
                    }
                }
                else
                {
                    var logvar = await PinApi_posing.LoginAsync();

                    var state = PinApi_posing.GetStateDataAsStream();
                    using (var fileStream = File.Create(stateFile))
                    {
                        state.Seek(0, SeekOrigin.Begin);
                        state.CopyTo(fileStream);
                    }
                }
            }
            catch (Exception ex)
            {
                Login.MainInstance.LogReport(true, PostingAccount, "Http Sesstion " + ex.Message);
                Login.MainInstance.GridControl_Tasks.BeginInvoke(new Action(() =>
                {
                    TaskMangerRow["Errors"] = (int.Parse(TaskMangerRow["Errors"].ToString()) + 1);
                }));
            }
        }
Ejemplo n.º 23
0
        private static IInstaApi CreateInstaApi(byte[] cookies, int requestDelayMin, int requestDelayMax)
        {
            IRequestDelay delay = RequestDelay.FromSeconds(requestDelayMin, requestDelayMax);

            var instaAPI = InstaApiBuilder.CreateBuilder()
                           .SetRequestDelay(delay)
                           .Build();

            instaAPI.LoadStateDataFromStream(new MemoryStream(cookies));

            return(instaAPI);
        }
Ejemplo n.º 24
0
 public Account(UserSessionData userSession)
 {
     this.userSession = userSession;
     InstaApi         = InstaApiBuilder.CreateBuilder()
                        .SetUser(userSession)
                        .UseLogger(new DebugLogger(LogLevel.All))        // use logger for requests and debug messages
                        .SetRequestDelay(RequestDelay.FromSeconds(2, 2)) //отсрочка запросов
                        .SetSessionHandler(new FileSessionHandler()
     {
         FilePath = (Environment.CurrentDirectory + PathContract.pathAccount + userSession.UserName + PathContract.stateFile)
     })
                        .Build();
 }
Ejemplo n.º 25
0
 IInstaApi BuildApi()
 {
     return(InstaApiBuilder.CreateBuilder()
            .SetUser(UserSessionData.ForUsername("FAKEUSERNAME").WithPassword("FAKEPASS"))
            .UseLogger(new DebugLogger(LogLevel.All))
            .SetRequestDelay(RequestDelay.FromSeconds(0, 1))
            // Session handler, set a file path to save/load your state/session data
            .SetSessionHandler(new FileSessionHandler()
     {
         FilePath = StateFile
     })
            .Build());
 }
Ejemplo n.º 26
0
        public async Task AuthAsync(string login, string password)
        {
            InstaApi = InstaApiBuilder.CreateBuilder()
                       .SetUser(new UserSessionData
            {
                UserName = login,
                Password = password
            })
                       .SetRequestDelay(RequestDelay.FromSeconds(0, 2))
                       .Build();

            RiseAuthStateChanged(await TryAuthAsync());
        }
Ejemplo n.º 27
0
 IInstaApi BuildApi()
 {
     return(InstaApiBuilder.CreateBuilder()
            .SetUser(UserSessionData.Empty)
            .UseLogger(new DebugLogger(LogLevel.All))
            .SetRequestDelay(RequestDelay.FromSeconds(0, 1))
            // Session handler, set a file path to save/load your state/session data
            .SetSessionHandler(new FileSessionHandler()
     {
         FilePath = StateFile
     })
            .Build());
 }
Ejemplo n.º 28
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);
            }
        }
Ejemplo n.º 29
0
        public async Task Run()
        {
            if (!CheckOK(false))
            {
                return;
            }

            var user = new UserSessionData
            {
                UserName = Login,
                Password = this.Password
            };

            if (api == null)
            {
                api = InstaApiBuilder.CreateBuilder()
                      .SetUser(user)
                      .UseLogger(new DebugLogger(LogLevel.Exceptions))
                      .SetRequestDelay(RequestDelay.FromSeconds(1, 3))
                      .Build();
            }
            var succ = await api.LoginAsync();

            if (!succ.Succeeded)
            {
                Task.Factory.StartNew(() => MessageBox.Show("Ошибка: " + succ.Info.Message, "Персонаж: " + name));
                return;
            }

            var curUser = await api.GetCurrentUserAsync();

            if (!curUser.Succeeded)
            {
                Task.Factory.StartNew(() => MessageBox.Show("Ошибка: " + curUser.Info.Message, "Персонаж: " + name));
                return;
            }


            working = true;


            Task[] tasks = { FirstMessages(), Answer(curUser.Value) };
            await Task.WhenAll(tasks);


            //await FirstMessages();
            //await Answer(curUser.Value.Pk);
            await api.LogoutAsync();
        }
Ejemplo n.º 30
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);
        }