Beispiel #1
0
        public static List <SMS> PullSMSStatus(string student, string Phone, ulong BeginTime, ulong EndTime)
        {
            Credential cred = new Credential
            {
                SecretId  = "AKIDqZ1DBslX2NUSJvv0U4RYP0LJ4YEeEnTu",
                SecretKey = "PULL6aoKagW5PSFp0sUqxiDSRGpg6EBu"
            };

            ClientProfile clientProfile = new ClientProfile();
            HttpProfile   httpProfile   = new HttpProfile();

            httpProfile.Endpoint      = ("sms.tencentcloudapi.com");
            clientProfile.HttpProfile = httpProfile;

            SmsClient client = new SmsClient(cred, "", clientProfile);
            PullSmsReplyStatusByPhoneNumberRequest req = new PullSmsReplyStatusByPhoneNumberRequest();

            req.PhoneNumber  = "+86" + Phone;
            req.SendDateTime = BeginTime;
            req.EndDateTime  = EndTime;
            req.Limit        = 10;
            req.SmsSdkAppid  = "1400410910";
            req.Offset       = 0;
            string strParams = Newtonsoft.Json.JsonConvert.SerializeObject(req);

            req = PullSmsReplyStatusByPhoneNumberRequest.FromJsonString <PullSmsReplyStatusByPhoneNumberRequest>(strParams);
            PullSmsReplyStatusByPhoneNumberResponse resp = client.PullSmsReplyStatusByPhoneNumberSync(req);

            Console.WriteLine(AbstractModel.ToJsonString(resp));
            List <SMS> ans = new List <SMS>();

            try
            {
                foreach (var x in resp.PullSmsReplyStatusSet)
                {
                    ans.Add(new SMS()
                    {
                        id_student   = student,
                        sendTime     = Convert.ToDateTime(x.ReplyTime),
                        type         = "PullResponse",
                        OperatorName = x.ReplyContent,
                        Status       = 1
                    });
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(ans);
        }