當前位置: 首頁>>代碼示例>>C#>>正文


C# TwilioRestClient.InitiateOutboundCall方法代碼示例

本文整理匯總了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);
		}
開發者ID:vmhung93,項目名稱:twilio-csharp,代碼行數:45,代碼來源:Twilio.cs

示例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);
            }
        }
開發者ID:cripas,項目名稱:pasteleria-net-cchar,代碼行數:27,代碼來源:HiloLlamada.cs

示例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);
        }
開發者ID:wadewegner,項目名稱:daily-affirmation,代碼行數:29,代碼來源:TwilioController.cs

示例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;
              }
        }
開發者ID:kzhen,項目名稱:RefUnited-IVR-Platform,代碼行數:32,代碼來源:SMSReceiverLogic.cs

示例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();
        }
開發者ID:hamamotsu,項目名稱:TwilioSample,代碼行數:32,代碼來源:Program.cs

示例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);
            }
        }
開發者ID:gstarbuck,項目名稱:NameMyBand,代碼行數:34,代碼來源:PhoneService.svc.cs

示例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!");
        }
開發者ID:yeahren,項目名稱:FlatteristSMS,代碼行數:31,代碼來源:SendMessagesController.cs

示例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);
        }
開發者ID:joelmartinez,項目名稱:onetug-twilio,代碼行數:10,代碼來源:RefTwilioController.cs

示例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);
        }
開發者ID:DragonRider0o0,項目名稱:HackGT,代碼行數:11,代碼來源:PhoneController.cs

示例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();
        }
開發者ID:joelmartinez,項目名稱:onetug-twilio,代碼行數:12,代碼來源:HomeController.cs

示例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";
        }
開發者ID:samarbasnet,項目名稱:RoundKit,代碼行數:13,代碼來源:HomeController.cs

示例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 });
        }
開發者ID:kwhinnery,項目名稱:jumpstart,代碼行數:13,代碼來源:HomeController.cs

示例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);
                {

            }
        }
開發者ID:taylorsmith4546,項目名稱:11-MeetupReminder,代碼行數:13,代碼來源:SmsService.cs

示例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");
        }
開發者ID:simondick,項目名稱:TwilioMakeAndReceiveCalls,代碼行數:14,代碼來源:HomeController.cs

示例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");
 }
開發者ID:ZhangYueqiu,項目名稱:asp5-mvc6-examples,代碼行數:15,代碼來源:HomeController.cs


注:本文中的Twilio.TwilioRestClient.InitiateOutboundCall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。