Пример #1
0
        private bool isCompress = false;//是否压缩,默认否


        public SMSResponseBody BatchSend(SMSRequestBody body)
        {
            SMSResponseBody responseBody = new SMSResponseBody();

            string    result   = "";
            Hashtable headerhs = new Hashtable();

            Byte[] byteArray = null;
            string jsondata  = "";
            string url       = "http://" + host + "/inter/sendPersonalitySMS";

            headerhs.Add("appId", appId);
            //jsondata = "{\"smses\":[{\"mobile\":15500000000,\"customSmsId\":null,\"content\":\"【短信签名】短信内容\"},{\"mobile\":15500000001,\"customSmsId\":null,\"content\":\"【短信签名】短信内容\"}],\"timerTime\":\"\",\"extendedCode\":112,\"requestTime\":" + DateTime.Now.Ticks.ToString() + ",\"requestValidPeriod\":30}";
            jsondata = JsonConvertEx.ObjectToJson(body);

            if (isCompress)
            {
                headerhs.Add("gzip", "on");//先压缩成byte再加密
                //byteArray = HttpHelper.postdata(url, AESHelper.AESEncrypt(GzipHelper.GZipCompressString(jsondata), secretKey), headerhs, Encoding.UTF8, secretKey);
            }
            else
            {
                byteArray = HttpHelper.postdata(url, AESHelper.AESEncrypt(jsondata, secretKey), headerhs, Encoding.UTF8, secretKey);
            }

            if (byteArray != null)
            {
                if (isCompress)
                {
                    //result = GzipHelper.DecompressString(AESHelper.AESDecrypt(byteArray, secretKey));
                }
                else
                {
                    result = AESHelper.AESDecryptString(byteArray, secretKey);
                }

                if (result != "")
                {
                    if (result.IndexOf("ERROR") != -1)
                    {
                        responseBody.flag       = false;
                        responseBody.resultCode = result;
                    }
                    else
                    {
                        responseBody.flag       = true;
                        responseBody.resultCode = "";
                        responseBody.smses      = JsonConvertEx.JsonToList <SMSResponseEntity>(result);
                    }

                    return(responseBody);
                }
            }

            AsyncHelper.RunSync <bool>(() => Manager.Instance.WriteLogFile("亿美发送msg出现问题"));
            return(null);
        }