73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Text;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.CRMServices.SMS.InterfaceModel;
|
|
|
|
namespace WX.CRM.CRMServices.SMS.InterfaceExec
|
|
{
|
|
public class TencentSms : IMsgSend
|
|
{
|
|
private readonly int _appId;
|
|
private readonly string _appKey;
|
|
public TencentSms(string appId = "", string appKey = "")
|
|
{
|
|
_appId = int.Parse(appId);
|
|
_appKey = appKey;
|
|
}
|
|
|
|
public ReturnResult Execute(string[] mobiles, string msg)
|
|
{
|
|
var mobilesStr = string.Join(",", mobiles);
|
|
var result = new ReturnResult
|
|
{
|
|
SendStr = mobilesStr,
|
|
ReturnStr = mobilesStr
|
|
};
|
|
try
|
|
{
|
|
// 短信应用SDK AppID
|
|
//int appid = 1400157076;
|
|
// 短信应用SDK AppKey
|
|
//string appkey = "7defb5fad78e9d28179d29d6a36896be";
|
|
|
|
var url = "http://47.107.128.102:8096/SmsService.svc/PutSms";
|
|
var smsUrl = Utility.GetSettingOrNullByKey("SmsUrl");
|
|
if (!string.IsNullOrEmpty(smsUrl))
|
|
{
|
|
url = smsUrl;
|
|
}
|
|
//var mobile = mobiles[0];
|
|
//var resid = ResUtil.CreateResId(mobile);
|
|
//var para = "message=" + msg + "&resid=" + resid + "&mobile=" + mobiles[0];
|
|
var para = JsonConvert.SerializeObject(new { message = msg, mobile = mobiles });
|
|
var res = Utility.PostAjaxData(url, para, Encoding.UTF8);
|
|
|
|
var resObj = JsonConvert.DeserializeObject<SmsResult>(res);
|
|
|
|
if (resObj.result)
|
|
result.submitStatus = SubmitStatus.success;
|
|
else
|
|
result.submitStatus = SubmitStatus.fail;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.submitStatus = SubmitStatus.fail;
|
|
LogHelper.Error("TencentSms.Send:" + ex.Message + ex.StackTrace);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public decimal queryAmt()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
private class SmsResult
|
|
{
|
|
public bool result { get; set; }
|
|
public int retcode { get; set; }
|
|
}
|
|
}
|
|
}
|