/// <summary> /// Logs out an account (sets cookies to null) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void btnAccountLogout_Click(object sender, EventArgs e) { var logout = await _instaApi.LogoutAsync(); btnAccountLogout.Enabled = false; if (logout.Succeeded) { _isLogged = false; lblAccountLoginStatus.Text = @"Status: Successfully logged out."; lblAccountLoginStatus.ForeColor = Color.DodgerBlue; Log($@"Successfully logged out as {txtAccountUsername.Text}.", nameof(LogType.Fail)); txtAccountUsername.Clear(); txtAccountPassword.Clear(); btnAccountLogin.Enabled = true; gbDownload.Enabled = false; } else { btnAccountLogout.Enabled = true; lblAccountLoginStatus.Text = @"Status: Failed to log out."; await Task.Delay(2000); lblAccountLoginStatus.Text = @"Status: Successfully logged in."; lblAccountLoginStatus.ForeColor = Color.Green; } }
public async Task DoShowWithProgress() { var mediaImage = new InstaImageUpload { // leave zero, if you don't know how height and width is it. Height = 0, Width = 0, Uri = "e/" + imagename1 }; // Add user tag (tag people) //mediaImage.UserTags.Add(new InstaUserTagUpload //{ // Username = "******", // X = 0.5, // Y = 0.5 //}); // Upload photo with progress //var result = await InstaApi.MediaProcessor.UploadPhotoAsync(UploadProgress, mediaImage, Content); //Console.WriteLine(result.Succeeded // ? $"Media created: {result.Value.Pk}, {result.Value.Caption}" // : $"Unable to upload photo: {result.Info.Message}"); await InstaApi.LogoutAsync(); }
public static async void Logout() { var device = new AndroidDevice { AndroidBoardName = "msm8996", AndroidBootloader = "G935TUVU3APG1", DeviceBrand = "samsung", DeviceModel = "SM-G935T", DeviceModelBoot = "qcom", DeviceModelIdentifier = "hero2qltetmo", FirmwareBrand = "hero2qltetmo", FirmwareFingerprint = "samsung/hero2qltetmo/hero2qltetmo:6.0.1/MMB29M/G935TUVU3APG1:user/release-keys", FirmwareTags = "release-keys", FirmwareType = "user", HardwareManufacturer = "samsung", HardwareModel = "SM-G935T", DeviceGuid = Guid.NewGuid(), PhoneGuid = Guid.NewGuid(), Resolution = "1440x2560", Dpi = "640dpi" }; api.SetDevice(device); var logoutRequest = await api.LogoutAsync(); Success("Logged out."); }
public async static Task <bool> Logout() { IResult <bool> logout_successful = await _instaApi.LogoutAsync(); await _instaApi.GetCurrentUserAsync(); return(logout_successful.Value); }
/// <summary> /// Logout the user from instagram /// </summary> /// <returns></returns> public bool Logout() { if (InstaClient.IsUserAuthenticated) { var logoutResult = InstaClient.LogoutAsync().Result; return(logoutResult.Succeeded); } return(true); }
public async Task <bool> LogoutAsync() { var logoutResult = await _instaApi.LogoutAsync(); if (logoutResult.Succeeded) { return(true); } return(false); }
public async Task <IHttpActionResult> Logout() { IInstaApi api = (IInstaApi)HttpContext.Current.Session["api"]; if (api == null || api.IsUserAuthenticated == false) { return(Ok()); } var result = await api.LogoutAsync(); return(Ok()); }
public static async Task <bool> Logout() { var logout = await InstaApi.LogoutAsync(); if (logout.Succeeded) { localSettings.Values["ihaveaaccount"] = "no"; localSettings.Values["LastUser"] = ""; Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile manifestFile = await storageFolder.GetFileAsync(_user + ".txt"); await manifestFile.DeleteAsync(); } return(logout.Succeeded); }
public async Task <bool> LogoutAsync() { bool isLoggedOut = false; if (_instaApi == null) { throw new NullReferenceException(); } IResult <bool> logout = await _instaApi.LogoutAsync(); isLoggedOut = logout.Succeeded; return(isLoggedOut); }
// protected override void OnStart() // { // // base.OnStart(); // } // protected override void OnRestart() // { // appOpenManager.Fetch(); // base.OnRestart(); // } private void logoutAsync(object sender, EventArgs e) { if (_instaApi != null) { _instaApi.LogoutAsync(); } if (_instaApi2 != null) { _instaApi2.LogoutAsync(); } File.Delete(stateFile); ActionBar.NavigationMode = ActionBarNavigationMode.Standard; ActionBar.RemoveAllTabs(); var activity = new Intent(this, typeof(MainActivity)); StartActivity(activity); Toast.MakeText(Application.Context, Resources.GetText(Resource.String.logout), ToastLength.Short).Show(); }
public static async Task <bool> MainAsync() { try { Console.WriteLine("Starting demo of InstaSharper project"); // create user session data and provide login details var userSession = new UserSessionData { UserName = "******", Password = "******" }; // create new InstaApi instance using Builder _instaApi = new InstaApiBuilder() .SetUser(userSession) .UseLogger(new DebugFileLogger()) // use logger for requests and debug messages .SetRequestDelay(TimeSpan.FromSeconds(1)) // set delay between requests .Build(); // login Console.WriteLine($"Logging in as {userSession.UserName}"); var logInResult = await _instaApi.LoginAsync(); if (!logInResult.Succeeded) { Console.WriteLine($"Unable to login: {logInResult.Info.Message}"); } else { Console.WriteLine("Press 1 to start basic demo samples"); Console.WriteLine("Press 2 to start upload photo demo sample"); Console.WriteLine("Press 3 to start comment media demo sample"); var key = Console.ReadKey(); Console.WriteLine(Environment.NewLine); switch (key.Key) { case ConsoleKey.D1: var basics = new Basics(_instaApi); await basics.DoShow(); break; case ConsoleKey.D2: var upload = new UploadPhoto(_instaApi); await upload.DoShow(); break; case ConsoleKey.D3: var comment = new CommentMedia(_instaApi); await comment.DoShow(); break; default: break; } Console.WriteLine("Done. Press esc key to exit..."); key = Console.ReadKey(); return(key.Key == ConsoleKey.Escape); } } catch (Exception ex) { Console.WriteLine(ex); } finally { var logoutResult = Task.Run(() => _instaApi.LogoutAsync()).GetAwaiter().GetResult(); if (logoutResult.Succeeded) { Console.WriteLine("Logout succeed"); } } return(false); }
public static async Task <bool> MainAsync() { try { Console.WriteLine("Starting demo of InstaSharper project"); // create user session data and provide login details var userSession = new UserSessionData { UserName = "******", Password = "******" }; // create new InstaApi instance using Builder var device = AndroidDeviceGenerator.GetByName(AndroidDevices.SAMSUNG_NOTE3); var requestMessage = ApiRequestMessage.FromDevice(device); _instaApi = InstaApiBuilder.CreateBuilder() .SetUser(userSession) .SetApiRequestMessage(requestMessage) .UseLogger(new DebugLogger(LogLevel.Info)) // use logger for requests and debug messages .SetRequestDelay(TimeSpan.FromSeconds(2)) .Build(); // login Console.WriteLine($"Logging in as {userSession.UserName}"); var logInResult = await _instaApi.LoginAsync(); if (!logInResult.Succeeded) { Console.WriteLine($"Unable to login: {logInResult.Info.Message}"); } else { Console.WriteLine("Press 1 to start basic demo samples"); Console.WriteLine("Press 2 to start upload photo demo sample"); Console.WriteLine("Press 3 to start comment media demo sample"); Console.WriteLine("Press 4 to start stories demo sample"); Console.WriteLine("Press 5 to start demo with saving state of API instance"); Console.WriteLine("Press 6 to start messaging demo sample"); var samplesMap = new Dictionary <ConsoleKey, IDemoSample> { [ConsoleKey.D1] = new Basics(_instaApi), [ConsoleKey.D2] = new UploadPhoto(_instaApi), [ConsoleKey.D3] = new CommentMedia(_instaApi), [ConsoleKey.D4] = new Stories(_instaApi), [ConsoleKey.D5] = new SaveLoadState(_instaApi), [ConsoleKey.D6] = new Messaging(_instaApi) }; var key = Console.ReadKey(); Console.WriteLine(Environment.NewLine); if (samplesMap.ContainsKey(key.Key)) { await samplesMap[key.Key].DoShow(); } Console.WriteLine("Done. Press esc key to exit..."); key = Console.ReadKey(); return(key.Key == ConsoleKey.Escape); } } catch (Exception ex) { Console.WriteLine(ex); } finally { var logoutResult = Task.Run(() => _instaApi.LogoutAsync()).GetAwaiter().GetResult(); if (logoutResult.Succeeded) { Console.WriteLine("Logout succeed"); } } return(false); }
protected override void OnCreate(Bundle savedInstanceState) { SetTheme(Resource.Style.MyTheme); base.OnCreate(savedInstanceState); ActionBar.Hide(); ActionBar.SetDisplayShowTitleEnabled(false); ActionBar.SetDisplayShowHomeEnabled(false); appOpenManager = new AppOpenManager(this, this); SetContentView(Resource.Layout.Main); Platform.Init(this, savedInstanceState); // Batteries.Init(); var button = FindViewById <Button>(Resource.Id.myButton); yuklemeBar = FindViewById <ProgressBar>(Resource.Id.progressBar1); txtEmail = FindViewById <EditText>(Resource.Id.tbEmail); txtPassword = FindViewById <EditText>(Resource.Id.tbPassword); CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>(); MobileAds.Initialize(this, "ca-app-pub-9927527797473679~9358311233"); userSession = new UserSessionData { UserName = "", Password = "" }; //var delay = RequestDelay.FromSeconds(2, 2); // create new InstaApi instance using Builder _instaApi2 = InstaApiBuilder.CreateBuilder() .SetRequestDelay(RequestDelay.FromSeconds(0, 0)) .Build(); _instaApi2.SetTimeout(TimeSpan.FromMinutes(10)); try { var status = CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>(); if (status.Result != PermissionStatus.Granted) { if (CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage).Result) { Toast.MakeText(Application.Context, Resources.GetText(Resource.String.fileperrmisson), ToastLength.Long) .Show(); } status = CrossPermissions.Current.RequestPermissionAsync <StoragePermission>(); } // load session file if exists if (File.Exists(stateFile)) { using var fs = File.OpenRead(stateFile); _instaApi2.LoadStateDataFromStream(fs); if (_instaApi2.IsUserAuthenticated) { // var result2 = Task.Run(async () => await _instaApi2.UserProcessor.GetUserFollowingAsync( // _instaApi2.GetLoggedUser().LoggedInUser.UserName, // PaginationParameters.MaxPagesToLoad(1))).Result; // var following = result2.Value; var result2 = Task.Run(async() => await _instaApi2.WebProcessor.GetAccountInfoAsync()); var following = result2.Result; if (!following.Succeeded) { _instaApi2.LogoutAsync(); File.Delete(stateFile); throw new InvalidOperationException("Oturum süreniz dolmuş"); } girisYapti(button, _instaApi2); } } } catch (Exception er) { HataGoster(er.Message); } button.Click += butonTiklandiAsync; }
public async Task Logout() { await instaApi.LogoutAsync(); }
public async Task <IResult <bool> > LogoutAsync() { return(await _instaApi.LogoutAsync()); }
public async Task Logout() { await instaApi.LogoutAsync(); DeleteSessionData(); }