コード例 #1
0
ファイル: TencentSmsTests.cs プロジェクト: yanh19930226/SMS
        public async void SendCodeTest()
        {
            var code = new TencentSmsSendCode {
                PhoneNumbers = new List <string> {
                    "13818167501"
                },
                Content = "验证码为12345"
            };

            var response = await _client.SendCodeAsync(code);

            Assert.True(response.Result == 0, JsonConvert.SerializeObject(response));
        }
コード例 #2
0
        public async Task <TencentSmsSendResponseData> SendCodeAsync(TencentSmsSendCode code)
        {
            if (code == null)
            {
                throw new ArgumentNullException(nameof(code));
            }
            if (_tencentAccount.AppId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(_tencentAccount.AppId));
            }
            if (string.IsNullOrWhiteSpace(_tencentAccount.AppKey))
            {
                throw new ArgumentNullException(nameof(_tencentAccount.AppKey));
            }

            code.CheckParameters();

            var single = code.PhoneNumbers.Count == 1;

            if (single)
            {
                var sender = _proxy.GetSingleSender();

                var response = sender.send(0, code.NationCode, code.PhoneNumbers[0], code.Content, "", "");

                return(Convert(response));
            }
            else
            {
                var sender = _proxy.GetMultiSender();

                var response = sender.send(0, code.NationCode, code.PhoneNumbers, code.Content, "", "");

                return(Convert(response));
            }
        }
コード例 #3
0
 public Task <TencentSmsSendResponseData> SendCodeAsync(TencentSmsSendCode code) => SendAsync(code);