本文整理汇总了C#中Twilio.TwilioRestClient类的典型用法代码示例。如果您正苦于以下问题:C# TwilioRestClient类的具体用法?C# TwilioRestClient怎么用?C# TwilioRestClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TwilioRestClient类属于Twilio命名空间,在下文中一共展示了TwilioRestClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendSms
public static Twilio.Message SendSms(string number, string content)
{
var formattedNumber = FormatPhoneNumber(number);
var restClient = new TwilioRestClient(_config.GetString(ACCOUNT_SID_KEY), _config.GetString(AUTH_TOKEN_KEY));
return restClient.SendMessage(_config.GetString(PHONE_NUMBER_KEY), formattedNumber, content);
}
开发者ID:mbgreen,项目名称:GHV,代码行数:7,代码来源:TwilioHelper.cs
示例2: SendMessage
private bool SendMessage(string toNumber,string textMsg)
{
try
{
string AccountSid = "AC04b7185526614dcdfcd8e03e0a5842a2";
string AuthToken = "976054e44e21b91c4af357f770f325fc";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
SMSMessage result = twilio.SendSmsMessage("+16782937535", toNumber, textMsg);
if (result.RestException != null)
{
//an exception occurred making the REST call
string message = result.RestException.Message;
}
return true;
}
catch (Exception)
{
return false;
}
// Find your Account Sid and Auth Token at twilio.com/user/account
}
开发者ID:shturner20,项目名称:EContact,代码行数:25,代码来源:MessageController.cs
示例3: TwilioSMSService
public TwilioSMSService(IOptions<SmsSettings> smsSettings)
{
_smsSettings = smsSettings.Value;
//TwilioClient.Init(_smsSettings.Sid, _smsSettings.Token);
_restClient = new TwilioRestClient(_smsSettings.Sid, _smsSettings.Token);
}
开发者ID:codefordenver,项目名称:shelter-availability,代码行数:7,代码来源:TwilioSMSService.cs
示例4: SendSmsMessage
private void SendSmsMessage(string username, MessageObject messageObj)
{
const string senderNumber = "+17245658130";
var twilioRestClient = new TwilioRestClient("AC47c7253af8c6fae4066c7fe3dbe4433c", "[AuthToken]");
var recipientNumber = Utils.GetNum(username);
twilioRestClient.SendMessage(senderNumber, recipientNumber, messageObj.ShortMessage, MessageCallback);
}
开发者ID:lshain,项目名称:Zuma,代码行数:7,代码来源:Complex2.cs
示例5: SendSms
/// <summary>
/// Send an SMS message
/// </summary>
/// <param name="from">The number to send the message from</param>
/// <param name="to">The number to send the message to</param>
/// <param name="body">The contents of the message, up to 160 characters</param>
/// <param name="statusCallbackUrl">The URL to notify of the message status</param>
/// <returns>An SMSMessage Instance resource</returns>
public static SMSMessage SendSms(string from, string to, string body, string statusCallbackUrl)
{
CheckForCredentials();
var twilio = new TwilioRestClient(AccountSid, AuthToken);
return twilio.SendSmsMessage(from, to, body, statusCallbackUrl);
}
开发者ID:vmhung93,项目名称:twilio-csharp,代码行数:15,代码来源:Twilio.cs
示例6: SendAsync
public Task SendAsync(IdentityMessage message)
{
// Twilio Begin
var Twilio = new TwilioRestClient(
System.Configuration.ConfigurationManager.AppSettings["SMSAccountIdentification"],
System.Configuration.ConfigurationManager.AppSettings["SMSAccountPassword"]);
var result = Twilio.SendMessage(
System.Configuration.ConfigurationManager.AppSettings["SMSAccountFrom"],
message.Destination, message.Body
);
//Status is one of Queued, Sending, Sent, Failed or null if the number is not valid
Trace.TraceInformation(result.Status);
//Twilio doesn't currently have an async API, so return success.
return Task.FromResult(0);
// Twilio End
// ASPSMS Begin
// var soapSms = new MvcPWx.ASPSMSX2.ASPSMSX2SoapClient("ASPSMSX2Soap");
// soapSms.SendSimpleTextSMS(
// System.Configuration.ConfigurationManager.AppSettings["SMSAccountIdentification"],
// System.Configuration.ConfigurationManager.AppSettings["SMSAccountPassword"],
// message.Destination,
// System.Configuration.ConfigurationManager.AppSettings["SMSAccountFrom"],
// message.Body);
// soapSms.Close();
// return Task.FromResult(0);
// ASPSMS End
}
开发者ID:rohitiscancerian,项目名称:VGWagers,代码行数:28,代码来源:SMSService.cs
示例7: SendSMS
public string SendSMS(TxtMsgOutbound txtMsgOutbound)
{
if (!AppConfigSvcValues.Instance.SmsSimulationMode && OnWhiteList(txtMsgOutbound.MobilePhone))
{
ThrottleCount++;
if (ThrottleCount >= ThrottleMax)
{
_log.Warning("MaxThrottle count exceeded: " + ThrottleMax);
}
else
{
string msg = string.Format("Sending SMS to {0}. message: '{1}'. ThrottleCount:{2}", txtMsgOutbound.MobilePhone, txtMsgOutbound.Message, ThrottleCount);
_log.Info(msg);
var twilio = new TwilioRestClient(AppConfigSvcValues.Instance.TwilioAccountSid, AppConfigSvcValues.Instance.TwilioAuthToken);
Message ret = twilio.SendMessage(AppConfigSvcValues.Instance.SourcePhone, txtMsgOutbound.MobilePhone, txtMsgOutbound.Message); //FutureDev: Send async
_log.Info("Sent SMS, status: " + ret.Status);
if (ret.Status != "queued")
_log.Info("Error. Send to Twilio not successful. Status:" + ret.Status + " destPhone:" + txtMsgOutbound.MobilePhone);
}
}
else
{
string reason = AppConfigSvcValues.Instance.SmsSimulationMode ? "Simulation" : "not on whitelist";
txtMsgOutbound.NotSendReason = reason;
_log.Info("NOT Sending SMS to " + txtMsgOutbound.MobilePhone + " at " + txtMsgOutbound.MobilePhone + ". message: '" + txtMsgOutbound.Message + "' because " + reason);
}
_txtMsgOutboundDal.UpdateState(txtMsgOutbound, TxtMsgProcessState.Processed);
return txtMsgOutbound.Id;
}
开发者ID:sgh1986915,项目名称:.net-braintree-spa,代码行数:33,代码来源:TwilioSmsSender.cs
示例8: SendTextMessage
public static void SendTextMessage(string message)
{
TwilioRestClient twilioClient = new TwilioRestClient
(ConfigurationManager.AppSettings["TwilioAcccountSid"], ConfigurationManager.AppSettings["TwilioAuthToken"]);
twilioClient.SendSmsMessage(ConfigurationManager.AppSettings["TwilioSenderPhone"],
ConfigurationManager.AppSettings["TwilioReceiverPhone"], message);
}
开发者ID:keyvan,项目名称:MiniHawraman,代码行数:7,代码来源:SmsManager.cs
示例9: SendSmsToAllInvolved
public static void SendSmsToAllInvolved(int orderId, string action)
{
IstokDoorsDBContext db = new IstokDoorsDBContext();
var employeesToInform = db.Employees.Where(i => i.IsSmsInformed == true).ToList();
string messageText;
if (action == "ship")
{
messageText = " Заказ " + orderId + " oтправлен! Проверьте Журнал Учёта Складских Запасов для дополнительной информации.";
}
else
{
messageText = " Заказ " + orderId + " oтменён! Проверьте Журнал Учёта Складских Запасов для дополнительной информации.";
}
var twilio = new TwilioRestClient(TwilioSender.AccountSid, TwilioSender.AuthToken);
if (employeesToInform != null)
{
foreach (var employee in employeesToInform)
{
var message = twilio.SendMessage(TwilioSender.PhoneNumber, employee.PhoneNumber1, messageText, "");
}
}
}
开发者ID:Cornevur,项目名称:IstokDoorsProject,代码行数:28,代码来源:MethodsForOrderHandling.cs
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string fromNumber = Request["From"];
string toNumber = Request["To"];
string smsBody = Request["Body"];
//check for invalid requests
if (string.IsNullOrEmpty(smsBody))
return;
var twilio = new TwilioRestClient(TWILIO_ACCOUNT_ID, TWILIO_AUTH_TOKEY);
//Parse the message body, get the language
SmsMessage smsMsg = new SmsMessage(smsBody);
//Get the Google translation controller
GoogleTranslateController translateController = new GoogleTranslateController();
//Get the language of the sms.
string smsLanguageCode = translateController.DetectLanguage(smsMsg.Content);
//Get the target language code.
string targetLanguageCode = translateController.GetLanguageCode(smsMsg.Language, smsLanguageCode);
//Get the translated message
string translatedMessage = translateController.TranslateText(smsMsg.Content, targetLanguageCode);
translatedMessage = HttpUtility.HtmlDecode(translatedMessage);
var message = twilio.SendMessage(toNumber, fromNumber, translatedMessage, "");
}
开发者ID:niofire,项目名称:Tingo,代码行数:29,代码来源:SmsReceiver.aspx.cs
示例11: Index
//
// GET: /SendMessages/
public ActionResult Index()
{
bool messages = true;
while (messages)
{
string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=ACCOUNTKEY";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("messages");
CloudQueueMessage retrievedMessage = queue.GetMessage();
if (retrievedMessage == null)
{
messages = false;
}
string phone = retrievedMessage.AsString;
var twilio = new TwilioRestClient("accountSid", "authToken");
var call = twilio.InitiateOutboundCall("+YOURTWILIONUMBER", phone, "http://YOURSITE.azurewebsites.net/LookupCompliment/");
queue.DeleteMessage(retrievedMessage);
}
return View("Complete!");
}
开发者ID:yeahren,项目名称:FlatteristSMS,代码行数:31,代码来源:SendMessagesController.cs
示例12: TwilioProvider
public TwilioProvider(string accountSid, string authToken)
{
this.authToken = authToken;
this.accountSid = accountSid;
client = new TwilioRestClient(accountSid, authToken);
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:7,代码来源:TwilioProvider.cs
示例13: SendSMS
public bool SendSMS(string number, string message)
{
var settings = _accountSettings.GetVoiceSettings();
var client = new TwilioRestClient(settings.AccountSid, settings.AuthToken);
if (number.IndexOf('+') < 0)
{
number = "+" + number.Trim();
}
var smsNumber = WebConfigurationManager.AppSettings["TwilioNumber"];
var result = client.SendMessage(smsNumber, number, message);
if (result.RestException != null)
{
_logger.Error($"Exception thrown sending SMS to {number}. Ex - {result.RestException.Message}");
}
if (result.Status != "queued")
{
_logger.Error($"SMS sent status - {result.Status}, {result.ErrorMessage}");
}
_logger.Debug($"Sending SMS to {number} with content {message}");
return result.Status == "queued";
}
开发者ID:letmeproperty,项目名称:callcentre,代码行数:25,代码来源:TwilioSmsController.cs
示例14: SendSMS
public TwilioSMSMessage SendSMS(string fromNumber, string toNumber, string text)
{
var twilio = new TwilioRestClient(SID, AuthToken);
try
{
var response = twilio.SendSmsMessage(fromNumber, toNumber, text);
if (response != null)
{
var message = new TwilioSMSMessage();
if (response.RestException != null)
{
message.ErrorCode = response.RestException.Code;
message.ErrorMessage = response.RestException.Message;
}
else
message.InjectFrom(response);
return message;
}
}
catch(Exception ex)
{
throw ex;
}
return null;
}
开发者ID:tonymishler,项目名称:ComputeMidwest,代码行数:30,代码来源:TwilioHelper.cs
示例15: TwilioCommunicationService
public TwilioCommunicationService(string accountSid, string authToken, string msgUrl)
{
messagingBaseUrl = msgUrl;
_client = new TwilioRestClient(accountSid, authToken);
_callOptions = new CallOptions();
}
开发者ID:mgolois,项目名称:DivineChMS,代码行数:7,代码来源:TwilioCommunicationService.cs
示例16: 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
示例17: ResponseToSms
public TwilioResponse ResponseToSms(SmsRequest request)
{
var response = new TwilioResponse();
try
{
string outboundPhoneNumber = request.From;
var client = new TwilioRestClient(accountSid, authToken);
var call = client.InitiateOutboundCall(
twilioPhoneNumber,
outboundPhoneNumber,
"http://refuniteivr.azurewebsites.net/api/IVREntry");
if (call.RestException == null)
{
response.Sms("starting call to " + outboundPhoneNumber);
}
else
{
response.Sms("failed call to " + outboundPhoneNumber + " " + call.RestException.Message);
}
return response;
}
catch (Exception ex)
{
response.Sms("exception: " + ex.Message);
return response;
}
}
开发者ID:kzhen,项目名称:RefUnited-IVR-Platform,代码行数:32,代码来源:SMSReceiverLogic.cs
示例18: GetNumberList
public static List<IncomingPhoneNumber> GetNumberList()
{
var twilio = new TwilioRestClient(GetSid(), GetToken());
var numbers = twilio.ListIncomingPhoneNumbers();
return numbers.IncomingPhoneNumbers;
}
开发者ID:bvcms,项目名称:bvcms,代码行数:7,代码来源:TwilioHelper.cs
示例19: SendPassButton_Click
protected void SendPassButton_Click(object sender, EventArgs e)
{
string MyNum = "16093850962";
string AcctID = "ACfe8686a211342fd1e55bb6654995c77f";
string AuthTok = "197a4597c18dff5f22208f12151e2d64";
TwilioRestClient clnt = new TwilioRestClient(AcctID, AuthTok);
clnt.SendSmsMessage(MyNum, ForgotTextBox.Text, "Yo What up");
SqlConnection cont = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
SqlCommand comm = new SqlCommand(@"Select Password from LoginTable where [email protected]", cont);
comm.Parameters.AddWithValue("@CellPhone", ForgotTextBox.Text);
cont.Open();
SqlDataReader DR = comm.ExecuteReader();
//Response.Write(DR["Password"].ToString());
}
开发者ID:pandyav,项目名称:pizzaApp-and-JobPortal,代码行数:26,代码来源:ForgotPass.aspx.cs
示例20: GetUnusedNumberList
public static List<TwilioNumber> GetUnusedNumberList()
{
var available = new List<TwilioNumber>();
var twilio = new TwilioRestClient(GetSid(), GetToken());
var numbers = twilio.ListIncomingPhoneNumbers();
var used = (from e in DbUtil.Db.SMSNumbers
select e).ToList();
for (var iX = numbers.IncomingPhoneNumbers.Count() - 1; iX > -1; iX--)
{
if (used.Any(n => n.Number == numbers.IncomingPhoneNumbers[iX].PhoneNumber))
numbers.IncomingPhoneNumbers.RemoveAt(iX);
}
foreach (var item in numbers.IncomingPhoneNumbers)
{
var newNum = new TwilioNumber();
newNum.Name = item.FriendlyName;
newNum.Number = item.PhoneNumber;
available.Add(newNum);
}
return available;
}
开发者ID:bvcms,项目名称:bvcms,代码行数:27,代码来源:TwilioHelper.cs
注:本文中的Twilio.TwilioRestClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论