当前位置: 首页>>代码示例>>C#>>正文


C# TwilioRestClient.Execute方法代码示例

本文整理汇总了C#中Twilio.TwilioRestClient.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# TwilioRestClient.Execute方法的具体用法?C# TwilioRestClient.Execute怎么用?C# TwilioRestClient.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twilio.TwilioRestClient的用法示例。


在下文中一共展示了TwilioRestClient.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        // Generate a random, unique code
        var uniqueCode = "1234567890";

        // Normally, we would call twilio.SendMessage() to send an SMS
        // But it doesn't support passing the ProvideFeedback parameter.
        var request = new RestRequest("Accounts/" + AccountSid + "/Messages.json", Method.POST);
        request.AddParameter("From", "+15017250604");
        request.AddParameter("To", "+15558675309");
        request.AddParameter("Body", "Open to confirm: http://yourserver.com/confirm?id=" + uniqueCode);
        request.AddParameter("ProvideFeedback", true);
        var response = twilio.Execute(request);

        var message = JsonConvert.DeserializeObject<Message>(response.Content,
            new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });

        Console.WriteLine("We should save this to a database:");
        Console.WriteLine("Unique Code = " + uniqueCode);
        Console.WriteLine("Message SID = " + message.Sid);
    }
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:26,代码来源:feedback-send-sms.4.x.cs

示例2: DownloadMessages

        public void DownloadMessages()
        {
            try
            {
                db = new VehicleDBEntities(Connection.GetConnectionString());
                var ps = db.ProjectSettings.FirstOrDefault();
                if (ps == null)
                    ps = new ProjectSetting() { StopSmsLogService = false, SmsLogUpdateDate = DateTime.Now.AddYears(-1), SmsLogRefreshTime = 1, };
                if (!ps.StopSmsLogService)
                {
                    var d = ps.SmsLogUpdateDate.Value;
                    var twilio = new TwilioRestClient(ConfigHelper.AppSetting("Twilio_AccountSid"), ConfigHelper.AppSetting("Twilio_AuthToken"));
                    var NowDate = DateTime.Now;
                    string resource = string.Format("Accounts/{0}/SMS/Messages.json?DateSent>={1}", ConfigHelper.AppSetting("Twilio_AccountSid"), d.ToString("yyyy-MM-dd HH:mm:ss"));
                    RestSharp.RestRequest rs = new RestSharp.RestRequest();
                    rs.Resource = resource;

                    var smsResult = twilio.Execute<SmsMessageResult>(rs);
                    var smsList = new List<Message>();
                    if (smsResult != null)
                        AutoMapper.Mapper.Map(smsResult.SMSMessages, smsList);
                    if (smsList.Count > 0)
                    {
                        foreach (var item in smsList)
                        {
                            if (!db.Messages.Any(p => p.Sid == item.Sid))
                                db.Messages.AddObject(item);
                        }
                        db.SaveChanges();
                    }
                    ps.SmsLogUpdateDate = NowDate;
                    if (ps.ID == 0)
                        db.ProjectSettings.AddObject(ps);
                    db.SaveChanges();
                    WriteLog(smsList.Count + " Sms read");
                }
                int interval = ps.SmsLogRefreshTime * 60 * 1000;
                if (timer1.Interval != interval)
                {
                    timer1.Stop();
                    timer1.Interval = interval;
                    timer1.Start();
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex.ToString());
            }
        }
开发者ID:mujassir,项目名称:vehicle_git_ivan,代码行数:49,代码来源:SmsLogService.cs

示例3: Index

    // GET: Confirm
    public ActionResult Index(string id)
    {
        // Lookup variable `id` in a database to find messageSid
        var messageSid = "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        // Find your Account Sid and Auth Token at twilio.com/console
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        // Send Feedback to Twilio
        var request = new RestRequest("Accounts/" + AccountSid +
            "/Messages/" + messageSid + "/Feedback.json", Method.POST);
        request.AddParameter("Outcome", "confirmed");
        twilio.Execute(request);

        // Handle remaining request normally
        return View();
    }
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:20,代码来源:feedback-confirm.4.x.cs

示例4: btnRefresh_Click

        protected void btnRefresh_Click(object sender, EventArgs e)
        {
            try
            {

                var twilio = new TwilioRestClient(ConfigHelper.AppSetting("Twilio_AccountSid"), ConfigHelper.AppSetting("Twilio_AuthToken"));
                var d = new DateTime(2013, 1, 31, 21, 28, 0);
                // string resource = string.Format("Accounts/{0}/SMS/Messages.json?DateSent>={1}", ConfigHelper.AppSetting("Twilio_AccountSid"), d.ToString("yyyy-MM-dd HH:mm:ss"));
                string resource = string.Format("Accounts/{0}/SMS/Messages.json?DateSent>={1}", ConfigHelper.AppSetting("Twilio_AccountSid"), d.ToString("yyyy-MM-dd HH:mm:ss"));
                RestSharp.RestRequest rs = new RestSharp.RestRequest();
                rs.Resource = resource;
                //var smsList = twilio.ListSmsMessages("", "", d, null, null);
                var smsResult = twilio.Execute<SmsMessageResult>(rs);
                var smsList = new List<Message>();
                AutoMapper.Mapper.Map(smsResult.SMSMessages, smsList);
                new MessageRepository().Add(smsList);
                ShowMessage(true, Resources.Messages.SmsLog_LogRefresh);

            }
            catch (Exception ex)
            {

                ShowMessage(false, ex.Message);
            }
        }
开发者ID:mujassir,项目名称:vehicle_git_ivan,代码行数:25,代码来源:SmsLog.aspx.cs


注:本文中的Twilio.TwilioRestClient.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。