GetToken() public static méthode

public static GetToken ( string number ) : string
number string
Résultat string
        public static bool RequestCode(string phoneNumber, out string password, out string request, out string response, string method = "sms", string id = null)
        {
            response = null;
            password = null;
            request  = null;
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    //auto-generate
                    id = GenerateIdentity(phoneNumber);
                }
                PhoneNumber pn    = new PhoneNumber(phoneNumber);
                string      token = System.Uri.EscapeDataString(WhatsRegisterV2.GetToken(pn.Number));

                request  = string.Format("https://v.whatsapp.net/v2/code?cc={0}&in={1}&to={0}{1}&method={2}&mcc={3}&mnc={4}&token={5}&id={6}&lg={7}&lc={8}", pn.CC, pn.Number, method, pn.MCC, pn.MNC, token, id, pn.ISO639, pn.ISO3166);
                response = GetResponse(request);
                password = response.GetJsonValue("pw");
                if (!string.IsNullOrEmpty(password))
                {
                    return(true);
                }
                return(response.GetJsonValue("status") == "sent");
            }
            catch (Exception e)
            {
                response = e.Message;
                return(false);
            }
        }
Exemple #2
0
        public static bool RequestCode(string phoneNumber, out string password, out string request, out string response, string method = "sms", string id = null)
        {
            response = null;
            password = null;
            request  = null;
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    //Auto-Generate
                    id = GenerateIdentity(phoneNumber);
                }
                PhoneNumber pn    = new PhoneNumber(phoneNumber);
                string      token = System.Uri.EscapeDataString(WhatsRegisterV2.GetToken(pn.Number));

                byte[] sha256bytes = new byte[20];
                new Random().NextBytes(sha256bytes);
                NameValueCollection QueryStringParameters = new NameValueCollection();
                QueryStringParameters.Add("cc", pn.CC);
                QueryStringParameters.Add("in", pn.Number);
                QueryStringParameters.Add("lg", pn.ISO639);
                QueryStringParameters.Add("lc", pn.ISO3166);
                QueryStringParameters.Add("id", id);
                QueryStringParameters.Add("token", token);
                QueryStringParameters.Add("mistyped", "6");
                QueryStringParameters.Add("network_radio_type", "1");
                QueryStringParameters.Add("simnum", "1");
                QueryStringParameters.Add("s", "");
                QueryStringParameters.Add("copiedrc", "1");
                QueryStringParameters.Add("hasinrc", "1");
                QueryStringParameters.Add("rcmatch", "1");
                QueryStringParameters.Add("pid", new Random().Next(100, 9999).ToString());
                QueryStringParameters.Add("rchash", BitConverter.ToString(HashAlgorithm.Create("sha256").ComputeHash(sha256bytes)));
                QueryStringParameters.Add("anhash", BitConverter.ToString(HashAlgorithm.Create("md5").ComputeHash(sha256bytes)));
                QueryStringParameters.Add("extexist", "1");
                QueryStringParameters.Add("extstate", "1");
                QueryStringParameters.Add("mcc", pn.MCC);
                QueryStringParameters.Add("mnc", pn.MNC);
                QueryStringParameters.Add("sim_mcc", pn.MCC);
                QueryStringParameters.Add("sim_mnc", pn.MNC);
                QueryStringParameters.Add("method", method);

                NameValueCollection RequestHttpHeaders = new NameValueCollection();
                RequestHttpHeaders.Add("User-Agent", WhatsConstants.UserAgent);
                RequestHttpHeaders.Add("Accept", "text/json");

                response = GetResponse("https://" + WhatsConstants.WhatsAppRequestHost, QueryStringParameters, RequestHttpHeaders);
                password = response.GetJsonValue("pw");
                if (!string.IsNullOrEmpty(password))
                {
                    return(true);
                }
                return(response.GetJsonValue("status") == "sent");
            }
            catch (Exception e)
            {
                response = e.Message;
                return(false);
            }
        }
Exemple #3
0
        public static bool RequestCode(string phoneNumber, out string password, out string request, out string response, string method = "sms", string id = null)
        {
            response = null;
            password = null;
            request  = null;
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    //auto-generate
                    id = GenerateIdentity(phoneNumber);
                }
                PhoneNumber pn    = new PhoneNumber(phoneNumber);
                string      token = System.Uri.EscapeDataString(WhatsRegisterV2.GetToken(pn.Number));

                request  = String.Format("https://v.whatsapp.net/v2/code?method={0}&in={1}&cc={2}&id={3}&lg=en&lc=US&token={4}&mcc=000&mnc=000&reason=self-send-jailbroken&network_radio_type=1", method, pn.Number, pn.CC, id, token);
                response = GetResponse(request);
                password = response.GetJsonValue("pw");
                if (!string.IsNullOrEmpty(password))
                {
                    return(true);
                }
                return(response.GetJsonValue("status") == "sent");
            }
            catch (Exception e)
            {
                response = e.Message;
                return(false);
            }
        }
        public static bool RequestCode(string countryCode, string phoneNumber, out string password, out string response, string method = "sms", string id = null, string language = null, string locale = null, string mcc = "204", string salt = "")
        {
            response = null;
            password = null;
            try
            {
                if (string.IsNullOrEmpty(language) || string.IsNullOrEmpty(locale))
                {
                    CultureInfo.CurrentCulture.GetLanguageAndLocale(out language, out locale);
                }
                if (string.IsNullOrEmpty(id))
                {
                    //auto-generate
                    id = GenerateIdentity(phoneNumber, salt);
                }
                string token = System.Uri.EscapeDataString(WhatsRegisterV2.GetToken(phoneNumber));

                string uri = string.Format("https://v.whatsapp.net/v2/code?cc={0}&in={1}&to={0}{1}&lg={2}&lc={3}&mcc={7}&mnc=008&method={4}&id={5}&token={6}", countryCode, phoneNumber, language, locale, method, id, token, mcc);
                response = GetResponse(uri);
                password = response.GetJsonValue("pw");
                if (!string.IsNullOrEmpty(password))
                {
                    return(true);
                }
                return(response.GetJsonValue("status") == "sent");
            }
            catch (Exception e)
            {
                response = e.Message;
                return(false);
            }
        }