Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.
This repository was archived by the owner on May 14, 2021. It is now read-only.

I get an error #2

@lencls37

Description

@lencls37

Challange required info is empty
try to call LoginAsync first.

But i already call ?

My Code;
`using CoreLib.Helpers;
using InstagramApiSharp.API.Builder;
using InstagramApiSharp.Classes;
using InstagramApiSharp.Logger;
using InstagramApiSharp.API;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace ISharp
{
public partial class Form1 : Form
{
public static IInstaApi api { get; set; }
public Form1()
{
InitializeComponent();
grp_Doğrulama.Visible = false;
textBox1.Enabled = false;
button1.Enabled = false;

    }

    public async void button1_Click(object sender, EventArgs e)
    {
        Form1 f1 = Application.OpenForms["Form1"] as Form1;
        var user = new UserSessionData
        {
            UserName = txt_Kadi.Text,
            Password = txt_Sifre.Text
        };
        api = InstaApiBuilder.CreateBuilder()
                    .SetUser(user)
                    .UseLogger(new DebugLogger(LogLevel.Exceptions))
                    .Build();
        var giris = await api.LoginAsync();
        if (giris.Succeeded)
        {
            var mevcutuser = await api.GetCurrentUserAsync();
            isimdegistir(mevcutuser.Value.UserName);
        }
        else
            switch (giris.Value)
            {
                case InstaLoginResult.InvalidUser:
                    MessageBox.Show("Yanlış kullanıcı adı");
                    break;
                case InstaLoginResult.BadPassword:
                    MessageBox.Show("Yanlış Şifre");
                    break;
                case InstaLoginResult.Exception:
                    MessageBox.Show("Exception throws:\n" + giris.Info?.Message);
                    break;
                case InstaLoginResult.LimitError:
                    MessageBox.Show("Limit Hatası(Tekrar denemeden önce 10 dakika bekleyiniz..)");
                    break;
                case InstaLoginResult.ChallengeRequired:
                    grp_Doğrulama.Visible = true;
                    break;
                case InstaLoginResult.TwoFactorRequired:
                    f1.grp_Doğrulama.Visible = true;
                    break;
            }

    }
    public void isimdegistir(string isim)
    {
        Form1 f1 = Application.OpenForms["Form1"] as Form1;
        f1.Text = "ISharper - " + isim;
    }

    private async void radio_Telefon_CheckedChanged(object sender, EventArgs e)
    {
        radio_Telefon.Enabled = false;
        radio_Mail.Enabled = false;
        var telefon = await api.RequestVerifyCodeToSMSForChallengeRequireAsync();
        if (telefon.Succeeded)
        {
            MessageBox.Show("Sms kutnuzu kontrol ediniz..");
        }
        else
        {
            MessageBox.Show(telefon.Info.Message);
        }
    }

    private async void radio_Mail_CheckedChanged(object sender, EventArgs e)
    {
        radio_Telefon.Enabled = false;
        radio_Mail.Enabled = false;
        var email = await api.RequestVerifyCodeToEmailForChallengeRequireAsync();
        if (email.Succeeded)
        {
            MessageBox.Show("Mail kutunuzu kontrol ediniz..");
        }
        else
            MessageBox.Show(email.Info.Message);
    }

    private async void btn_KodGonder_Click(object sender, EventArgs e)
    {
        txt_Kod.Text.Replace(" ", "");
        var regex = new Regex(@"^-*[0-9,\.]+$");
        if (!regex.IsMatch(txt_Kod.Text))
        {
            MessageBox.Show("Doğrulama kodu sayı olmalıdır!!!");
            return;
        }
        if (txt_Kod.Text.Length != 6)
        {
            MessageBox.Show("Doğrulama kodu 6 haneli bir sayı olmalıdır!!!");
            return;
        }
        var dogrulama = await api.VerifyCodeForChallengeRequireAsync(txt_Kod.Text);
        if (dogrulama.Succeeded)
        {
            isimdegistir("ISharp - Doğrulama başarılı");
        }
        else
        {
            if (dogrulama.Value == InstaLoginResult.TwoFactorRequired)
            {
                MessageBox.Show("İki faktörlü doğrulama gerekiyor.");
                button1.Enabled = true;
                textBox1.Enabled = true;
            }
        }

    }

    private async void button1_Click_1(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(textBox1.Text))
        {
            MessageBox.Show("Lütfen 2 faktörlü doğrulama kodunu yazın ve gönderin.");
            return;
        }
        try
        {
            var ikifaktor = await api.TwoFactorLoginAsync(textBox1.Text);
            if (ikifaktor.Succeeded)
            {
                isimdegistir("ISharp - Giriş Başarılı");
            }
            else
            {
                MessageBox.Show(ikifaktor.Info.Message);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
}

}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions