Exemplo n.º 1
0
        /// <summary>
        /// 检查短信剩余条数
        /// </summary>
        /// <returns></returns>
        public override string CheckRemain()
        {
            string url = _serverUrl + "/" + _queryBlance;
            var request = new HttpPost(url) {
                                                ContentEncoding = "UTF-8"
                                            };
            request.Params.Add("CorpID", _username);
            request.Params.Add("Pwd", _pwd);

            string result = request.Request();

            if (result != " ") {
                return "还剩" + result + "条";
            }
            if (result == "-1") {
                return "帐号未注册!";
            }
            if (result == "-2") {
                return "其他错误!";
            }
            if (result == " -3") {
                return "帐号密码不匹配!";
            }

            if (string.IsNullOrWhiteSpace(result)) {
                throw new ApplicationException("调用远程短信发送接口,返回未知的状态错误。");
            }
            return result;
        }
Exemplo n.º 2
0
        public override void Send(string phoneNo, string content, object userToken, CompletedCallback callback)
        {
            const string url = ServerUrl + SendMsgMethod;
            var request = new HttpPost(url)
            {
                ContentEncoding = "UTF-8"
            };
            request.Params.Add("apikey", _apiKey);
            request.Params.Add("mobile", phoneNo);
            request.Params.Add("text",  "【】" + content);

            request.Request();
        }
Exemplo n.º 3
0
        public override void Send(string phoneNo, string content)
        {
            const string url = ServerUrl + SendMsgMethod;
            var request = new HttpPost(url)
            {
                ContentEncoding = "UTF-8"
            };
            request.Params.Add("apikey", _apiKey);
            request.Params.Add("mobile", phoneNo);
            request.Params.Add("text", "【】" + content);

            var result = request.Request();

            var args = GetEventArgs(result, null);

            if (args.Error != null)
            {
                throw args.Error;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="phoneNo"></param>
        /// <param name="content"></param>
        public override void Send(string phoneNo, string content)
        {
            string url = _serverUrl + "/" + _sendMsgMethod;
            var request = new HttpPost(url)
            {
                ContentEncoding = "gb2312"
            };
            request.Params.Add("CorpID", _username);
            request.Params.Add("Pwd", _pwd);
            request.Params.Add("Mobile", phoneNo);
            request.Params.Add("Content", content);
            request.Params.Add("Cell", "");
            request.Params.Add("SendTime","");

            string result = request.Request();

            AsyncCompletedEventArgs args = GetEventArgs(result, null);

            if (args.Error != null) {
                throw args.Error;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="phoneNo">发送的手机号</param>
        /// <param name="content">发送的内容</param>
        /// <param name="userToken">回调标识对象 </param>
        /// <param name="callback">回调函数</param>
        public override void Send(string phoneNo, string content, object userToken, CompletedCallback callback)
        {
            string url = _serverUrl + "/" + _sendMsgMethod;
            var request = new HttpPost(url) {
                                                ContentEncoding="gb2312"
                                            };
            request.Params.Add("CorpID", _username);
            request.Params.Add("Pwd", _pwd);
            request.Params.Add("Mobile", phoneNo);
            request.Params.Add("Content", content);
            request.Params.Add("Cell", "");
            request.Params.Add("SendTime","");

            try {
                string result = request.Request();

                callback(request, GetEventArgs(result, userToken));
            }
            catch (Exception ex) {
                callback(request, new AsyncCompletedEventArgs(ex, false, userToken));
            }
        }