本文整理汇总了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);
}
示例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());
}
}
示例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();
}
示例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);
}
}