public async Task <MainLoginModel> UpdateLoginModel() { var info = await _instaApi.GetCurrentUserAsync(); var model = new MainLoginModel { CurrentUser = info.Value }; var followers = await _instaApi.GetUserFollowersAsync(info.Value.UserName, PaginationParameters.MaxPagesToLoad(15)); model.Followers = followers.Value; var following = await _instaApi.GetUserFollowingAsync(info.Value.UserName, PaginationParameters.MaxPagesToLoad(15)); model.Following = following.Value; return(model); }
public async Task <MainLoginModel> StartLoginAsync(Credential credential) { var userSession = new UserSessionData { UserName = credential.UserName, Password = credential.Password }; var delay = RequestDelay.FromSeconds(1, 2); _instaApi = InstaApiBuilder.CreateBuilder().SetUser(userSession).UseLogger(new DebugLogger(LogLevel.Exceptions)) .SetRequestDelay(delay).Build(); if (_instaApi.IsUserAuthenticated) { return(null); } // login Debug.WriteLine($"Logging in as {userSession.UserName}"); delay.Disable(); var logInResult = await _instaApi.LoginAsync(); delay.Enable(); if (!logInResult.Succeeded) { Debug.WriteLine($"Unable to login: {logInResult.Info.Message}"); return(null); } else { // await UserProfile.InitData(_instaApi); MainLoginModel model = await UpdateLoginModel(); return(model); } }