コード例 #1
0
        /// <summary>
        /// 向指定的手机发送短信验证码。
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <returns></returns>
        public async Task <string> SendValidationCodeAsync(string phoneNumber)
        {
            using (var client = new ValidationCodeSvc.VerificationCodeClient())
            {
                var result = await client.SendAsync(phoneNumber);

                if (result.StatusCode != 0)
                {
                    throw new InvalidOperationException("发送验证码时出现无效操作,代码" + result.StatusCode + ",消息:" + result.Message);
                }

                return(result.VerificationCode);
            }
        }