Exemplo n.º 1
0
        private void btnCodeRequest_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(this.txtPhoneNumber.Text))
            {
                if (this.radVoice.Checked)
                {
                    this.method = "voice";
                }
                try
                {
                    this.number = this.txtPhoneNumber.Text;
                    this.TrimNumber();
                    WhatsAppApi.Parser.PhoneNumber phonenumber = new WhatsAppApi.Parser.PhoneNumber(this.number);
                    this.identity = WhatsAppApi.Register.WhatsRegisterV2.GenerateIdentity(phonenumber.Number, this.txtPassword.Text);
                    this.cc       = phonenumber.CC;
                    this.phone    = phonenumber.Number;
                    this.language = phonenumber.ISO639;
                    this.locale   = phonenumber.ISO3166;
                    this.mcc      = phonenumber.MCC;

                    CountryHelper chelp   = new CountryHelper();
                    string        country = string.Empty;
                    if (!chelp.CheckFormat(this.cc, this.phone, out country))
                    {
                        string msg = string.Format("Provided number does not match any known patterns for {0}", country);
                        this.Notify(msg);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    string msg = String.Format("Error: {0}", ex.Message);
                    this.Notify(msg);
                    return;
                }
                string response = null;
                if (WhatsAppApi.Register.WhatsRegisterV2.RequestCode(this.cc, this.phone, out this.password, out response, this.method, this.identity, this.language, this.locale, this.mcc))
                {
                    if (!string.IsNullOrEmpty(this.password))
                    {
                        //password received
                        this.OnReceivePassword();
                    }
                    else
                    {
                        this.grpStep1.Enabled = false;
                        this.grpStep2.Enabled = true;
                    }
                }
                else
                {
                    string msg = string.Format("Could not request verification code\r\n{0}", response);
                    this.Notify(msg);
                }
            }
            else
            {
                this.Notify("Please enter a phone number");
            }
        }
Exemplo n.º 2
0
        private void CliRequestCode()
        {
            this.GetArgs();
            this.TrimNumber();
            try
            {
                WhatsAppApi.Parser.PhoneNumber pn = new WhatsAppApi.Parser.PhoneNumber(this.number);
                this.identity = WhatsAppApi.Register.WhatsRegisterV2.GenerateIdentity(pn.Number, this.password);
                CountryHelper ch       = new CountryHelper();
                string        country  = string.Empty;
                string        response = string.Empty;
                if (ch.CheckFormat(pn.CC, pn.Number, out country))
                {
                    bool result = WhatsAppApi.Register.WhatsRegisterV2.RequestCode(pn.CC, pn.Number, out this.password, out response, this.method, null, pn.ISO639, pn.ISO3166, pn.MCC, this.password);

                    //return raw
                    if (this.raw)
                    {
                        Console.WriteLine(response);
                        return;
                    }

                    if (result)
                    {
                        if (!string.IsNullOrEmpty(this.password))
                        {
                            Console.WriteLine("Got password:"******"Code requested");
                        }
                    }
                    else
                    {
                        if (response == "iplimit")
                        {
                            Console.WriteLine("Daily 10 unique phone number limit reached.");
                            Console.WriteLine("Try again tomorrow or email me at [email protected] to add you to my whitelist");
                        }
                        else
                        {
                            Console.WriteLine("Error:");
                            Console.WriteLine(response);
                        }
                    }
                }
                else
                {
                    Console.WriteLine(string.Format("Invalid phone number for {0}", country));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 3
0
        private void CliRequestCode()
        {
            this.GetArgs();
            this.TrimNumber();
            try
            {
                WhatsAppApi.Parser.PhoneNumber pn = new WhatsAppApi.Parser.PhoneNumber(this.number);
                this.identity = WhatsAppApi.Register.WhatsRegisterV2.GenerateIdentity(pn.Number, this.password);
                CountryHelper ch       = new CountryHelper();
                string        country  = string.Empty;
                string        response = string.Empty;
                if (ch.CheckFormat(pn.CC, pn.Number, out country))
                {
                    bool result = WhatsAppApi.Register.WhatsRegisterV2.RequestCode(this.number, out this.password, out response, this.method, this.identity);

                    //return raw
                    if (this.raw)
                    {
                        Console.WriteLine(response);
                        return;
                    }

                    if (result)
                    {
                        if (!string.IsNullOrEmpty(this.password))
                        {
                            Console.WriteLine("Got password:"******"Code requested");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error:");
                        Console.WriteLine(response);
                    }
                }
                else
                {
                    Console.WriteLine(string.Format("Invalid phone number for {0}", country));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 4
0
        private void btnExist_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(this.txtPhoneNumber.Text))
            {
                try
                {
                    this.number = this.txtPhoneNumber.Text;
                    this.TrimNumber();
                    WhatsAppApi.Parser.PhoneNumber phonenumber = new WhatsAppApi.Parser.PhoneNumber(this.number);
                    this.identity = WhatsAppApi.Register.WhatsRegisterV2.GenerateIdentity(phonenumber.Number, this.txtPassword.Text);
                    this.cc       = phonenumber.CC;
                    this.phone    = phonenumber.Number;

                    CountryHelper chelp   = new CountryHelper();
                    string        country = string.Empty;
                    if (!chelp.CheckFormat(this.cc, this.phone, out country))
                    {
                        string msg = string.Format("Provided number does not match any known patterns for {0}", country);
                        this.Notify(msg);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    string msg = String.Format("Error: {0}", ex.Message);
                    this.Notify(msg);
                    return;
                }
                string response = null;
                this.password = WhatsAppApi.Register.WhatsRegisterV2.RequestExist(this.number, out response, this.identity);

                if (!string.IsNullOrEmpty(this.password))
                {
                    //password received
                    this.OnReceivePassword();
                }
                else
                {
                    string msg = string.Format("Could not verify existing registration\r\n{0}", response);
                    this.Notify(msg);
                }
            }
            else
            {
                this.Notify("Please enter a phone number");
            }
        }
Exemplo n.º 5
0
        private void CliRegisterCode()
        {
            this.GetArgs();
            this.TrimNumber();
            try
            {
                WhatsAppApi.Parser.PhoneNumber pn = new WhatsAppApi.Parser.PhoneNumber(this.number);
                this.identity = WhatsAppApi.Register.WhatsRegisterV2.GenerateIdentity(pn.Number, password);
                CountryHelper ch      = new CountryHelper();
                string        country = string.Empty;
                if (ch.CheckFormat(pn.CC, pn.Number, out country))
                {
                    string response = string.Empty;
                    this.password = WhatsAppApi.Register.WhatsRegisterV2.RegisterCode(pn.CC, pn.Number, this.code, out response, null, this.password);

                    //return raw
                    if (this.raw)
                    {
                        Console.WriteLine(response);
                        return;
                    }

                    if (String.IsNullOrEmpty(this.password))
                    {
                        Console.WriteLine("Code not accepted");
                    }
                    else
                    {
                        Console.WriteLine("Got password:"******"Invalid number for {0}", country));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(String.Format("Error: {0}", e.Message));
            }
        }
Exemplo n.º 6
0
        private bool parseNumber()
        {
            this.debug = this.chkDebug.Checked;
            if (!String.IsNullOrEmpty(this.txtPhoneNumber.Text))
            {
                try
                {
                    this.number = this.txtPhoneNumber.Text;
                    this.TrimNumber();
                    WhatsAppApi.Parser.PhoneNumber phonenumber = new WhatsAppApi.Parser.PhoneNumber(this.number);
                    this.identity = WhatsAppApi.Register.WhatsRegisterV2.GenerateIdentity(phonenumber.Number, this.txtPassword.Text);
                    this.cc       = phonenumber.CC;
                    this.phone    = phonenumber.Number;

                    CountryHelper chelp   = new CountryHelper();
                    string        country = string.Empty;
                    if (!chelp.CheckFormat(this.cc, this.phone, out country))
                    {
                        string msg = string.Format("Provided number does not match any known patterns for {0}", country);
                        this.Notify(msg);
                        return(false);
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    string msg = String.Format("Error: {0}", ex.Message);
                    this.Notify(msg);
                }
            }
            else
            {
                this.Notify("Please enter a phone number");
            }
            return(false);
        }
Exemplo n.º 7
0
        private void btnCodeRequest_Click(object sender, EventArgs e)
        {
            this.debug = this.chkDebug.Checked;
            if (!String.IsNullOrEmpty(this.txtPhoneNumber.Text))
            {
                if (this.radVoice.Checked)
                {
                    this.method = "voice";
                }
                try
                {
                    this.number = this.txtPhoneNumber.Text;
                    this.TrimNumber();
                    WhatsAppApi.Parser.PhoneNumber phonenumber = new WhatsAppApi.Parser.PhoneNumber(this.number);
                    this.identity = WhatsAppApi.Register.WhatsRegisterV2.GenerateIdentity(phonenumber.Number, this.txtPassword.Text);
                    this.cc       = phonenumber.CC;
                    this.phone    = phonenumber.Number;

                    CountryHelper chelp   = new CountryHelper();
                    string        country = string.Empty;
                    if (!chelp.CheckFormat(this.cc, this.phone, out country))
                    {
                        string msg = string.Format("Provided number does not match any known patterns for {0}", country);
                        this.Notify(msg);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    string msg = String.Format("Error: {0}", ex.Message);
                    this.Notify(msg);
                    return;
                }

                string request  = null;
                string response = null;

                bool registerResult = WhatsAppApi.Register.WhatsRegisterV2.RequestCode(this.number, out this.password, out request, out response, this.method, this.identity);

                if (this.debug)
                {
                    this.Notify(string.Format(@"Code Request:
Token = {0}
Identity = {1}
User Agent = {2}
Request = {3}
Response = {4}", WhatsAppApi.Register.WhatsRegisterV2.GetToken(this.phone), this.identity, WhatsAppApi.Settings.WhatsConstants.UserAgent, request, response));
                }

                if (registerResult)
                {
                    if (!string.IsNullOrEmpty(this.password))
                    {
                        //password received
                        this.OnReceivePassword();
                    }
                    else
                    {
                        this.grpStep1.Enabled = false;
                        this.grpStep2.Enabled = true;
                    }
                }
                else
                {
                    string msg = string.Format("Could not request verification code\r\n{0}", response);
                    this.Notify(msg);
                }
            }
            else
            {
                this.Notify("Please enter a phone number");
            }
        }