當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。