本文整理汇总了C#中Twilio.TwilioRestClient.InitiateOutboundCall方法的典型用法代码示例。如果您正苦于以下问题:C# TwilioRestClient.InitiateOutboundCall方法的具体用法?C# TwilioRestClient.InitiateOutboundCall怎么用?C# TwilioRestClient.InitiateOutboundCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twilio.TwilioRestClient
的用法示例。
在下文中一共展示了TwilioRestClient.InitiateOutboundCall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeCall
/// <summary>
/// Initiate a new outgoing call
/// </summary>
/// <param name="from">The phone number to call from</param>
/// <param name="to">The phone number to call to</param>
/// <param name="url">The TwiML URL to use for controlling this call</param>
/// <param name="statusCallback">The URL to notify upon completion of the call</param>
/// <param name="statusCallbackMethod">The HTTP method to use when requesting the statusCallback URL</param>
/// <param name="fallbackUrl">The URL to request upon encountering an in-call error</param>
/// <param name="fallbackMethod">The HTTP method to use when requesting the fallbackUrl</param>
/// <param name="ifMachine">The action to take when encountering an answering machine</param>
/// <param name="sendDigits">The DTMF touch tone digits to transmit when the call is answered</param>
/// <param name="timeout">The amount of time to allow a call to ring before ending</param>
/// <returns>A Call Instance resource</returns>
public static Call MakeCall(string from, string to, string url, string statusCallback,
string statusCallbackMethod, string fallbackUrl, string fallbackMethod,
string ifMachine, string sendDigits, int? timeout = null)
{
CheckForCredentials();
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var options = new CallOptions();
options.From = from;
options.To = to;
if (!string.IsNullOrEmpty(url))
{
options.Url = url;
}
else
{
options.Url = HttpContext.Current.Request.Url.ToString();
}
options.StatusCallback = statusCallback;
options.StatusCallbackMethod = statusCallbackMethod;
options.FallbackUrl = fallbackUrl;
options.FallbackMethod = fallbackMethod;
options.IfMachine = ifMachine;
options.SendDigits = sendDigits;
options.Timeout = timeout;
return twilio.InitiateOutboundCall(options);
}
示例2: lanzar
public void lanzar()
{
try
{
// Find your Account Sid and Auth Token at twilio.com/user/account
string AccountSid = "AC5ee97f763eb14e6754a03570fcd1b269";
string AuthToken = "3fec4bfd5ff5cd6379df62ac78a0e460";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
string url = "http://tiendapasteleria.esy.es/texttospeechc.php?Message%5B0%5D=";
url += "Estimado " + ped.contacto_nom + " " + ped.contacto_ape + " este es un mensaje de la pasteleria San Elias. Le Notificamos que su pedido numero " + ped.idpedido + " esta " + ped.estado.descrip + " .Que tenga un buen dia";
url = url.Replace(" ", "%20");
// Build the parameters
var options = new CallOptions();
options.Url = url;
options.To = "+51" + "979085281";
options.From = "+12019890396";
var call = twilio.InitiateOutboundCall(options);
Console.WriteLine(call.Sid);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
示例3: Get
public string Get([FromUri] string phoneNumber, string flatteristId, string flattery)
{
const string accountSid = "YOURSIDE";
const string authToken = "YOURTOKEN";
const string fromNumber = "YOURNUMBER";
var client = new TwilioRestClient(accountSid, authToken);
if (string.IsNullOrEmpty(flattery))
{
var call = client.InitiateOutboundCall(
fromNumber, // The number of the phone initiating the call
string.Format("+{0}", phoneNumber), // The number of the phone receiving call
string.Format("http://www.flatterist.com/{0}.mp3", flatteristId)
// The URL Twilio will request when the call is answered
);
if (call.RestException == null)
{
return string.Format("Started call: {0}", call.Sid);
}
return string.Format("Error: {0}", call.RestException.Message);
}
client.SendMessage(fromNumber, phoneNumber, flattery);
return string.Format("Sent message to {0}", phoneNumber);
}
示例4: 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;
}
}
示例5: Main
static void Main(string[] args)
{
System.Console.WriteLine("通話を開始します。何かキーを入力してください。");
System.Console.ReadKey();
var accountSid = "12345";
var authToken = "abcde";
var twilioPhonenumber = "+815098765432";
var client = new TwilioRestClient(accountSid, authToken);
var options = new CallOptions();
options.Url = "http://hogehoge.net/twiliosample/callbound";
options.To = "+819012345678";
options.From = twilioPhonenumber;
options.IfMachine = "Continue";
var call = client.InitiateOutboundCall(options);
if (call.RestException == null)
{
System.Console.WriteLine("通話を開始しました");
System.Console.WriteLine(string.Format("Started call: {0}", call.Sid));
}
else
{
System.Console.WriteLine("通話は異常終了しました。");
System.Console.WriteLine(string.Format("Error: {0}", call.RestException.Message));
}
System.Console.ReadKey();
}
示例6: MakeCall
public string MakeCall(string number, string message)
{
// Set our Account SID and AuthToken
string accountSid = "AC955c4ca6365eb7628db4829d6a04966f";
string authToken = "bb63e780836aa018a012fd97f64f7b5f";
// A phone number you have previously validated with Twilio
string phonenumber = "+16085127391";
// Instantiate a new Twilio Rest Client
var client = new TwilioRestClient(accountSid, authToken);
// Initiate a new outbound call
client.InitiateOutboundCall(
phonenumber, // The number of the phone initiating the call
"+1" + number.ToString(), // The number of the phone receiving call
call => {
WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
var x = new XmlDocument();
x.LoadXml("<x>SpecialMessage</x>");
return x;
}
//"http://demo.twilio.com/welcome/voice/" // The URL Twilio will request when the call is answered
);
if (call.RestException == null)
{
return string.Format("Started call: {0}", call.Sid);
}
else
{
return string.Format("Error: {0}", call.RestException.Message);
}
}
示例7: 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!");
}
示例8: txt2
public ActionResult txt2(SmsRequest request)
{
Demo.LogNumber(request);
TwilioRestClient t = new TwilioRestClient(Constants.SID, Constants.AuthToken);
t.InitiateOutboundCall(request.To, request.From, "http://onetugdemo.apphb.com/reftwilio/voice2");
TwilioResponse response = new TwilioResponse();
return TwiML(response);
}
示例9: SendCall
public void SendCall(string targetNumber)
{
string twilioNumber = "+18014299303";
string accountSid = "AC2cbe631411b305e102ac2e3ce2da0407";
string authToken = "9093223b161f8d4a9a97577b5cddbc20";
var client = new TwilioRestClient(accountSid, authToken);
var url = "http://safetynet.azurewebsites.net/phone/GetCallTwiml";
client.InitiateOutboundCall(twilioNumber, targetNumber, url);
}
示例10: Random
public ActionResult Random()
{
CallOptions call = new CallOptions
{
From = Demo.GetRandom().Number,
To = Demo.GetRandom().Number
};
var twilio = new TwilioRestClient(Constants.SID, Constants.AuthToken);
twilio.InitiateOutboundCall(call);
return View();
}
示例11: GetCallPhone
public string GetCallPhone()
{
string AccountSid = "AC250c475896904f3249306f633df6d114";
string AuthToken = "ed3be1bdddedf301c711c4ee33f0e185";
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var options = new CallOptions();
options.Url = "http://demo.twilio.com/docs/voice.xml";
options.To = "+18179466874";
options.From = "+18179622556";
var call = twilio.InitiateOutboundCall(options);
return "sucess";
}
示例12: Call
public ActionResult Call(string to)
{
client = new TwilioRestClient(Settings.AccountSid, Settings.AuthToken);
var result = client.InitiateOutboundCall(Settings.TwilioNumber, to, Settings.BaseUrl + Url.Action("Hello"));
if (result.RestException!=null)
{
return new System.Web.Mvc.HttpStatusCodeResult(500, result.RestException.Message);
}
return Json(new { error=false });
}
示例13: MakeACall
public static void MakeACall(string to, string message)
{
var twilio = new TwilioRestClient(TwilioAccountSid, TwilioAuthToken);
var co = new CallOptions();
co.To = to;
twilio.InitiateOutboundCall(co);
{
}
}
示例14: MakeCall
public ActionResult MakeCall(string number)
{
// Instantiate new Rest API object
var client = new TwilioRestClient(Settings.AccountSid, Settings.AuthToken);
var result = client.InitiateOutboundCall(Settings.MyTwilioNumber, number, "http://www.televisiontunes.com/uploads/audio/Star%20Wars%20-%20The%20Imperial%20March.mp3");
// return any exceptions that may occur
if (result.RestException != null)
{
return Content(result.RestException.Message);
}
return Content("The call has been is initiated");
}
示例15: MakeCall
public IActionResult MakeCall(string number)
{
var client = new TwilioRestClient(
_twilioSettings.Options.AccountSid,
_twilioSettings.Options.AuthToken
);
var results = client.InitiateOutboundCall(
_twilioSettings.Options.MyOwnNumber,
number, "http://www.televisiontunes.com/uploads/audio/Star%20Wars%20-%20The%20Imperial%20March.mp3");
if (results.RestException != null)
{
return Content(results.RestException.Message);
}
return Content("The call has been is initiated");
}