Beispiel #1
0
        public static Tuple <bool, string> Send(string addr, string message)
        {
            const string strApplicationId = "P000000000000111";
            const string strUrl           = "http://221.178.190.165:6118/services/cmcc_mas_wbs";

            var wbs = new cmcc_mas_wbs();

            wbs.Url = strUrl;
            var uri     = System.Uri.EscapeUriString("tel:" + addr);
            var request = new sendSmsRequest()
            {
                ApplicationID        = strApplicationId,
                DestinationAddresses = new[] { uri },
                MessageFormat        = MessageFormat.GB2312,
                SendMethod           = SendMethodType.Long,
                Message = message,
                DeliveryResultRequest = true
            };

            try
            {
                var identify = wbs.sendSms(request).RequestIdentifier;
                return(new Tuple <bool, string>(true, identify));
            }
            catch (Exception ex)
            {
                return(new Tuple <bool, string>(false, ex.Message));
            }
        }
Beispiel #2
0
        /// <summary>
        /// CMCC短信服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static string CMCC(string mobilePhone, string msgContent)
        {
            ConfigurationManager.RefreshSection("appSettings");
            string ws_addr  = ConfigurationManager.AppSettings["WS_ADDR"] ?? "";
            string ws_appid = ConfigurationManager.AppSettings["WS_APPID"] ?? "";

            try
            {
                cmcc_mas_wbs wbs = new cmcc_mas_wbs();
                wbs.Url = ws_addr;
                sendSmsRequest smsreq = new sendSmsRequest();
                smsreq.ApplicationID = ws_appid;
                //smsreq.DeliveryResultRequest = true;
                smsreq.DestinationAddresses = new string[] { "tel:" + mobilePhone }; //手机号码
                smsreq.Message       = msgContent;                                   //短信内容
                smsreq.MessageFormat = MessageFormat.GB2312;
                smsreq.SendMethod    = SendMethodType.Long;
                sendSmsResponse rsp          = wbs.sendSms(smsreq);
                string          sendResultID = rsp.RequestIdentifier;//返回的唯一标识符
                //GetSmsDeliveryStatusRequest GetSmsDeliveryStatusRequest = new GetSmsDeliveryStatusRequest();
                //GetSmsDeliveryStatusRequest.ApplicationID = ws_appid;
                //GetSmsDeliveryStatusRequest.ApplicationID = sendResultID;

                return(sendResultID /*+"&"+ sendResultID*/);
            }
            catch (Exception ex)
            {
                log("短信服务出错");
                return("false");
            }
        }