예제 #1
0
        public ApiResult SendRaw(string token, string mobile, string message, string ipAddress)
        {
            var url = BuildQueryUri(_sendRawUrl);
            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "token", token }
            };
            var data   = DataFormatter.FromObject(new { mobile, message, IpAddress = ipAddress });
            var result = Connector.Post(url, parameters, data);

            return(DataFormatter.ToObject <ApiResult <SecretKeyAuthentication> >(result));
        }
예제 #2
0
        public T Post <T>(string apiUrl, object para = null)
        {
            var uri = BuildQueryUri(apiUrl);

            try {
                var data   = DataFormatter.FromObject(para);
                var result = Connector.Post(uri, data);
                return(DataFormatter.ToObject <T>(result));
            } catch (Exception ex) {
                throw new SystemException($"{apiUrl}网络请求失败,{ex.Message}");
            }
        }
예제 #3
0
        /// <summary>
        ///     发送手机验证码
        /// </summary>
        /// <param name="token"></param>
        /// <param name="mobile"></param>
        /// <param name="userIpAddress"></param>
        /// <returns></returns>
        public ApiResult CheckMobileVerifiyCode(string token, string mobile, string userIpAddress, long code)
        {
            var url = BuildQueryUri(_checkPhoneVerifiyCode);
            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "token", token },
                { "ipaddress", userIpAddress }
            };
            var data   = DataFormatter.FromObject(new { mobile, IpAddress = userIpAddress, code });
            var result = Connector.Post(url, parameters, data);

            return(DataFormatter.ToObject <ApiResult>(result));
        }
예제 #4
0
        /// <summary>
        ///     发送手机验证码
        /// </summary>
        /// <param name="token"></param>
        /// <param name="mobile"></param>
        /// <param name="userIpAddress"></param>
        /// <returns></returns>
        public ApiResult SendMobileVerifiyCode(string token, string mobile, string userIpAddress)
        {
            var url = BuildQueryUri(_sendPhoneVerifiyCode);
            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "token", token },
                { "ipaddress", userIpAddress }
            };

            try {
                var data   = DataFormatter.FromObject(new { mobile, IpAddress = userIpAddress });
                var result = Connector.Post(url, parameters, data);
                return(DataFormatter.ToObject <ApiResult>(result));
            } catch (Exception ex) {
                return(ApiResult.Failure(ex.Message));
            }
        }
예제 #5
0
        public ApiResult SendTemplate(string token, string mobile, long templateId, string userIpAddress,
                                      IDictionary <string, string> parameter = null)
        {
            var url = BuildQueryUri(_sendTemplateUrl);
            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "token", token },
                { "ipaddress", userIpAddress }
            };
            var data = DataFormatter.FromObject(new {
                templateid = templateId,
                mobile,
                parameters = DataFormatter.FromObject(parameter)
            });
            var result = Connector.Post(url, parameters, data);

            return(DataFormatter.ToObject <ApiResult <SecretKeyAuthentication> >(result));
        }
예제 #6
0
        public async Task <ApiResult> SendTemplateAsync(string token, string mobile, long templateId,
                                                        string userIpAddress, IDictionary <string, string> parameter = null)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            var url = BuildQueryUri(_sendTemplateUrl);
            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "token", token },
                { "ipaddress", userIpAddress }
            };
            var data = DataFormatter.FromObject(new {
                templateid = templateId,
                mobile,
                parameters = DataFormatter.FromObject(parameter),
                IpAddress  = userIpAddress
            });
            var result = await Connector.PostAsync(url, parameters, data);

            return(DataFormatter.ToObject <ApiResult <SecretKeyAuthentication> >(result));
        }