Пример #1
0
        public void Send()
        {
            var token = GetToken();

            if (string.IsNullOrWhiteSpace(token))
            {
                throw new Exception($@"{nameof(token) } is null");
            }

            var restVerificationCode = new RestVerificationCode()
            {
                Code         = "1234567890",
                MobileNumber = "09353429089"
            };

            RestVerificationCodeRespone restVerificationCodeRespone = new VerificationCode().Send(token, restVerificationCode);

            if (restVerificationCodeRespone == null)
            {
                throw new Exception($@"{nameof(restVerificationCodeRespone) } is null");
            }

            if (restVerificationCodeRespone.IsSuccessful)
            {
            }
            else
            {
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");



            var token = new Token().GetToken("apiKey", "secretKey");

            var restVerificationCode = new RestVerificationCode()
            {
                Code         = "1234567890",
                MobileNumber = "09120000001"
            };

            var restVerificationCodeRespone = new VerificationCode().Send(token, restVerificationCode);

            Console.WriteLine(restVerificationCodeRespone.Message);


            if (restVerificationCodeRespone.IsSuccessful)
            {
            }
            else
            {
            }
            Console.ReadLine();
        }
Пример #3
0
        public Task SendSmsAsync(string number, string message)
        {
            if (smtp.UsePickupFolder)
            {
                string path = $@"{smtp.PickupFolder}\{number}.txt";
                if (!File.Exists(path))
                {
                    // Create a file to write to.
                    using (StreamWriter sw = File.CreateText(path))
                    {
                        sw.WriteLine($"{number}");
                        sw.WriteLine($"Verification code: {message}");
                    }
                }
            }
            else
            {
                SmsIrRestful.Token tk     = new SmsIrRestful.Token();
                string             result = tk.GetToken("f102ae793839867ae1ee90f4", "d@k@nB2z1&2&3@VN@87134");

                RestVerificationCode messageSendObject = new RestVerificationCode()
                {
                    Code         = message,
                    MobileNumber = number
                };
                RestVerificationCodeRespone restVerificationCodeRespone = new VerificationCode().Send(result, messageSendObject);
            }

            return(Task.FromResult(0));
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            var token = new Token().GetToken("8c239fb1b71d69d65d17a1c6", "!@#test!@#");

            txtToken.Text = token;
            gettoken      = token;

            SmsLineNumber credit = new SmsLine().GetSmsLines(token);



            if (credit == null)
            {
                throw new Exception($@"{nameof(credit) } is null");
            }

            if (credit.IsSuccessful)
            {
                for (int i = 0; i < credit.SMSLines.Length; i++)
                {
                    txtFrom.Text = credit.SMSLines[i].LineNumber.ToString();
                }

                Random r = new Random();

                //Generate 10 random numbers
                for (int i = 1; i <= 10; i++)
                {
                    //Console.WriteLine(r.Next());
                    string co = r.Next().ToString();
                    codevery = co;
                }


                var restVerificationCode = new RestVerificationCode()

                {
                    Code         = codevery,
                    MobileNumber = txtTo.Text
                };

                var restVerificationCodeRespone = new VerificationCode().Send(gettoken, restVerificationCode);

                if (restVerificationCodeRespone.IsSuccessful)
                {
                    MessageBox.Show("پیامک شما با موفقیت ارسال شد", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("ERROR", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static bool SendVerificationCode(string ApiKey, string SecurityCode, string verificationCode, string mobileNumber)
        {
            var restVerificationCode = new RestVerificationCode()
            {
                Code         = verificationCode,
                MobileNumber = mobileNumber,
            };
            string token = TokenSmsIr(ApiKey, SecurityCode);
            var    restVerificationCodeRespone = new VerificationCode().Send(token, restVerificationCode);

            if (restVerificationCodeRespone.IsSuccessful)
            {
                return(true);
            }
            return(false);
        }
Пример #6
0
        /// <summary>
        /// Send Sms Function
        /// </summary>
        /// <param name="lineNumber"></param>
        /// <param name="userApiKey"></param>
        /// <param name="phoneNumber"></param>
        /// <param name="message"></param>
        /// <param name="secrectKey"></param>
        /// <returns></returns>
        public override async Task <OperationResult <string> > Send(string lineNumber, string userApiKey, string phoneNumber, string message, string secrectKey)
        {
            var token = new Token().GetToken(userApiKey, secrectKey);

            var restVerificationCode = new RestVerificationCode()
            {
                Code         = message,
                MobileNumber = phoneNumber
            };

            var restVerificationCodeRespone = new VerificationCode().Send(token, restVerificationCode);

            if (restVerificationCodeRespone.IsSuccessful)
            {
                return(OperationResult <string> .BuildSuccessResult(restVerificationCodeRespone.Message));
            }
            return(OperationResult <string> .BuildFailure(restVerificationCodeRespone.Message));
        }