Available options to include when initiating a phone call
Esempio n. 1
1
        private static void AddCallOptions(CallOptions options, RestRequest request)
        {
            request.AddParameter("From", options.From);
            request.AddParameter("To", options.To);

            if (options.ApplicationSid.HasValue())
            {
                request.AddParameter("ApplicationSid", options.ApplicationSid);
            }
            else
            {
                request.AddParameter("Url", options.Url);
            }

            if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
            if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);
            if (options.FallbackUrl.HasValue()) request.AddParameter("FallbackUrl", options.FallbackUrl);
            if (options.FallbackMethod.HasValue()) request.AddParameter("FallbackMethod", options.FallbackMethod);
            if (options.Method.HasValue()) request.AddParameter("Method", options.Method);
            if (options.SendDigits.HasValue()) request.AddParameter("SendDigits", options.SendDigits);
            if (options.IfMachine.HasValue()) request.AddParameter("IfMachine", options.IfMachine);
            if (options.Timeout.HasValue) request.AddParameter("Timeout", options.Timeout.Value);
            if (options.Record) request.AddParameter("Record", "true");
            if (options.SipAuthUsername.HasValue()) request.AddParameter("SipAuthUsername", options.SipAuthUsername);
            if (options.SipAuthPassword.HasValue()) request.AddParameter("SipAuthPassword", options.SipAuthPassword);
        }
        public TwilioCommunicationService(string accountSid, string authToken, string msgUrl)
        {
            messagingBaseUrl = msgUrl;
            _client = new TwilioRestClient(accountSid, authToken);
            _callOptions = new CallOptions();

        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
		/// <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);
		}
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Initiates a new phone call. Makes a POST request to the Calls List resource.
        /// </summary>
        /// <param name="options">Call settings. Only properties with values set will be used.</param>
        public virtual Call InitiateOutboundCall(CallOptions options)
        {
            Require.Argument("From", options.From);
            Require.Argument("To", options.To);

            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/Calls.json";
            
            AddCallOptions(options, request);

            return Execute<Call>(request);
        }
        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();
        }
        public static void MakeACall(string to, string message)
        {
            var twilio = new TwilioRestClient(TwilioAccountSid, TwilioAuthToken);

            var co = new CallOptions();

            co.To = to;

            twilio.InitiateOutboundCall(co);
                {

            }
        }
Esempio n. 9
0
        /// <summary>
        /// Initiates a new phone call.
        /// </summary>
        /// <param name="options">Call settings. Only properties with values set will be used.</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public void InitiateOutboundCall(CallOptions options, Action<Call> callback)
        {
            Require.Argument("From", options.From);
            Require.Argument("To", options.To);
            Require.Argument("Url", options.Url);

            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallOptions(options, request);

            ExecuteAsync<Call>(request, (response) => callback(response));
        }
Esempio n. 10
0
        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";
        }
Esempio n. 11
0
        //
        // GET: /Route/
        public ActionResult SMS()
        {
            string AccountSid = "AC466fd9c5fb1ec783e26fd56c3b25970b";
            string AuthToken = "896c359e5a927cbddc2a38d36f1a264c";
            var twilio = new TwilioRestClient(AccountSid, AuthToken);

            var options = new CallOptions();
            options.Url = "http://twiliorouter.apphb.com/Route/SMSInstructions?Message=" + HttpUtility.UrlEncode(Request["Body"]);
            //options.To = "+17202808698";
            options.To = Request["From"];
            options.From = "+17202591415";
            var call = twilio.InitiateOutboundCall(options);
            //Response.Write(options.Url);
            //Console.WriteLine(call.Sid);
            return View();
        }
Esempio n. 12
0
        public static void OutgoingCall(string url, string toNumber, int contactGroup,int notification)
        {
            var accountSid = ConfigurationManager.AppSettings["TwilioAccountSid"];
            var authToken = ConfigurationManager.AppSettings["TwilioAuthToken"];
            var applicationSid = ConfigurationManager.AppSettings["ApplicationSid"];
            var from = ConfigurationManager.AppSettings["TwilioNumber"];

            var twilio = new TwilioRestClient(accountSid, authToken);

            var options = new CallOptions();
            options.From = from;
            options.Url = url + "?ContactGroupId=" + contactGroup + "&NotificationId=" + notification;
            options.ApplicationSid = applicationSid;
            options.Method = "POST";
            options.Record = false;

            var call = twilio.InitiateOutboundCall(options);
        }
Esempio n. 13
0
        private void btn_Call_Click(object sender, EventArgs e)
        {
            // Find your Account Sid and Auth Token at twilio.com/user/account
            string AccountSid = "ACd80adc88fe6a85be2e789aa0f866b661";
            string AuthToken = "db4cc0d6a7b98e9d42583cbd57d819d2";
            var twilio = new TwilioRestClient(AccountSid, AuthToken);

            // Build the parameters
            var options = new CallOptions();
            options.To = "+1"+tbx_Number.Text;
            options.From = "+15812000231";
            options.Url = "https://www.google.ca/?gfe_rd=cr&#38;ei=dBiUVb26IYaN8Qeo0oGABQ";
            options.Method = "GET";
            options.FallbackMethod = "GET";
            options.StatusCallbackMethod = "GET";
            options.Record = false;

            var call = twilio.InitiateOutboundCall(options);
            Console.WriteLine(call.Sid);
        }
Esempio n. 14
0
        public string SendCall(string Message, string phone )
        {
            string error = "";
            string FROM = Twilio_FromNumber;
            var client = new TwilioRestClient(Twilio_AccountSid, Twilio_AuthtTok);
            CallOptions options = new CallOptions();

            options.From = FROM;
            options.To = phone;

            options.Url = WebURL + "twiliomessagesHandler.ashx?message=" + HttpContext.Current.Server.UrlEncode(Message) + "";

            // Place the call.
            var call = client.InitiateOutboundCall(options);

             if  (call.RestException != null )
             { error = call.RestException.Message; }

             return error;
        }
Esempio n. 15
0
        public static void OutgoingCall(string url, string toNumber)
        {
            var accountSid = ConfigurationManager.AppSettings["TwilioAccountSid"];
            var authToken = ConfigurationManager.AppSettings["TwilioAuthToken"];
            //var applicationSid = ConfigurationManager.AppSettings["ApplicationSid"];
            var from = ConfigurationManager.AppSettings["TwilioNumber"];

            var twilio = new TwilioRestClient(accountSid, authToken);

            var options = new CallOptions();
            options.To = toNumber;
            options.From = from;
            options.Url = url;

            var call = twilio.InitiateOutboundCall(options);

            if (call.RestException != null)
            {
                string temp = call.RestException.Message;
            }
        }
        protected void btn_Click(object sender, EventArgs e)
        {
            string accountSid = "AC49ecef1b877e244ea13ada1b5fe92b85";
            //string applicationsid = "AP5556f6cd1af5cfa5317acae7a49eeb5c";
            string sid = "CA748c6019014ca0ac151908a81299f927";
            string authToken = "4eeeaf7ed6459dcd02ec7888149d5ea1";
            string recordingSid = "RE5dabfb2da314b39cd87dc151bf669e78";
               DateTime datecreated=DateTime.Now;
            TwilioRestClient client;
            client = new TwilioRestClient(accountSid, authToken);
            string APIversuion = client.ApiVersion;
            string TwilioBaseURL = client.BaseUrl;

            Account account = client.GetAccount(accountSid);
            client.GetRecording(recordingSid);
            client.GetRecordingText(recordingSid);
            client.ListRecordings(sid, datecreated, 1, 2);
            client.ListQueues();
            client.ListIncomingPhoneNumbers();
            this.varDisplay.Items.Clear();
            if (this.txtcall.Text == "" || this.message.Text == "")
            { this.varDisplay.Items.Add( "You must enter a phone number and a message."); } else { // Retrieve the values entered by the user.
                string to = this.txtcall.Text;
                string myMessage = this.message.Text;
                //string Url = "http://demo.twilio.com/Welcome/Call/";
            String Url = "http://twimlets.com/message?Message%5B0%5D=" + myMessage.Replace(" ", "%20");
                // Diplay the enpoint, API version, and the URL for the message.
                this.varDisplay.Items.Add("Using Tilio endpoint " + TwilioBaseURL);
                this.varDisplay.Items.Add("Twilioclient API Version is " + APIversuion);
                this.varDisplay.Items.Add("The URL is " + Url); // Instantiate the call options that are passed // to the outbound call.
                CallOptions options = new CallOptions(); // Set the call From, To, and URL values into a hash map. // This sample uses the sandbox number provided by Twilio // to make the call.
                options.From = "+14242165015";
                options.To = to;
                options.Url = Url; // Place the call.
                options.Record = true;
                var call = client.InitiateOutboundCall(options);
                this.varDisplay.Items.Add("Call status: " + call.Status); }
        }
Esempio n. 17
0
        /// <summary>
        /// Dial from Twilio number to user mobile number
        /// </summary>
        /// <param name="url">URL of TwiML for instruction Twilio make a call</param>
        /// <param name="number">Phone number of specialist</param>
        /// <returns></returns>
        public Call Dial(string url, string number)
        {
            var options = new CallOptions
            {
                Url = Utilities.FormatLink(url),
                To = number,
                From = AppSettings.PhoneTwilio,
                StatusCallback = Utilities.FormatLink(CallConst.CallBackUrl),
                StatusCallbackMethod = "POST"
            };

            var call = Client.InitiateOutboundCall(options);

            if (call.RestException != null)
            {
                throw new Exception(string.Format("Error making call. {0} {1}", call.RestException.Message, call.RestException.MoreInfo));
            }
            return call;
        }
Esempio n. 18
0
        private static void OnMessage(string serializedData)
        {
            lock (_SenderLock)
            {
                try
                {
                    if (!_Config.SendToList.Any()) return;

                    string messageBody = "Message Received: \n" + serializedData;

                    if (_SmtpClient != null)
                    {
                        foreach (var mailTo in _ToAddress)
                        {
                            try
                            {
                                MailMessage myMessage = new MailMessage(_FromAddress, mailTo)
                                {
                                    Subject = _Config.MessageSubject,
                                    Body = messageBody
                                };

                                _SmtpClient.Send(myMessage);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }

                    if (_SendGridTransportWeb != null)
                    {
                        SendGridMessage myMessage = new SendGridMessage(
                            _FromAddress,
                            _ToAddress,
                            _Config.MessageSubject,
                            string.Empty,
                            messageBody
                            );

                        _SendGridTransportWeb.DeliverAsync(myMessage).Wait();
                    }

                    if (_TwilioRestClient != null)
                    {

                        switch (_NotificationService)
                        {
                            case NotificationServiceType.Twilio:
                                {
                                    foreach (var smsTo in _Config.SendToList)
                                    {
                                        try
                                        {
                                            _TwilioRestClient.SendMessage(_Config.MessageFromAddress, smsTo,
                                                messageBody);
                                        }
                                        catch (Exception)
                                        {
                                        }
                                    }
                                }
                                break;
                            case NotificationServiceType.TwilioCall:
                                {
                                    string callUrl = "http://twimlets.com/message?Message%5B0%5D=" + WebUtility.UrlEncode(_Config.MessageSubject);

                                    foreach (var callTo in _Config.SendToList)
                                    {
                                        try
                                        {
                                            CallOptions options = new CallOptions
                                            {
                                                From = _Config.MessageFromAddress,
                                                To = callTo,
                                                Url = callUrl
                                            };

                                            Call call = _TwilioRestClient.InitiateOutboundCall(options);
                                        }
                                        catch (Exception)
                                        {
                                        }
                                    }
                                }
                                break;
                        }
                    }
                }
                catch (Exception)
                {
                    Trace.WriteLine("Exception on mail sending...");
                }
            }
        }
        //Call User on Click with Verification Code
        private void loginWindow_button_CallUse_Click(object sender, RoutedEventArgs e)
        {
            //Get Users Phone Number
            string UsersPhoneNumber = grabPhoneNumber();

            //If users number is null, stop Method.
            if (UsersPhoneNumber == null)
            {
                return;
            }

            //Generate Random 10 Digit Code for user
            //Save Randomly Generated Number
            RandomGeneratedNumber = GenerateRandomNumber();

            RandomGeneratedNumberString = RandomGeneratedNumber.ToString();
            //Find your Account Sid and Auth Token
            string AccountSid = "AC61b76d7cf5033d39d3fdf1a6816e3e61";
            string AuthToken = "1f4545334cf64e12d68a224de622178c";
            string myTwilioPhoneNumber = "+16508351288";

            //Create XML file and save Locally
            XDocument RandomlyGeneratedNumberXMLFile = writeXMLFile(RandomGeneratedNumberString);
            SaveXMLFileLocally(RandomlyGeneratedNumberXMLFile);

            //Write to FTP
            WriteToFTP(FullFilePath);

            //Instantaiate a new Twilio Rest Client
            var client = new TwilioRestClient(AccountSid, AuthToken);

            //Build Call Option
            var options = new CallOptions();
            //  options.Url = "C:\\Users\\jward01\\Documents\\Visual Studio 2015\\Projects\\WPFSMSAuth\\ContactManagementApp\\TwilioVoice.xml";
            // options.Url = "http://demo.twilio.com/docs/voice.xml";

            //Get file from FTP Server

            options.To = UsersPhoneNumber;
            options.From = myTwilioPhoneNumber;
            options.Url = "http://jeffwarddevelopment.com/twilio_calls/call.xml";
            options.Method = "GET";
            options.FallbackMethod = "GET";
            options.StatusCallbackMethod = "GET";
            options.Record = false;

            //Initiate a new Outbound Call
            var call = client.InitiateOutboundCall(options);

               // var twilio = new TwilioRestClient(AccountSid, AuthToken);
               // var message = twilio.SendMessage(myTwilioPhoneNumber, UsersPhoneNumber, "Hello, I am the computer security guard!  Here is your 10-digit pass code: +" + RandomGeneratedNumberString + ".");
            MessageBox.Show("Users phone number: " + UsersPhoneNumber);
            MessageBox.Show("Here is your number: " + RandomGeneratedNumberString);
        }
        /// <summary>
        /// Initiates an outgoing twilio call that calls customer phone, redirects to thinq at the time when the customer accepts the call.
        /// </summary>
        /// <param name="from">'from' number</param>
        /// <param name="to">'to' number</param>
        /// <returns>call sid if successful, error message otherwise</returns>
        public String call(String from, String to)
        {
            if(!this.isClientValid()) {
                return "Invalid Twilio Account details.";
            }

            try{
                var options = new CallOptions();
                options.Url = TWIML_RESOURCE_URL;
                options.To = "sip:" + to + "@" + THINQ_DOMAIN + "?thinQid=" + this.thinQ_id + "&thinQtoken=" + this.thinQ_token;
                options.From = from;
                var call = this.client.InitiateOutboundCall(options);
                return call.Sid;
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Redirect a call in progress to a new TwiML URL.  Makes a POST request to a Call Instance resource.
        /// </summary>
        /// <param name="callSid">The Sid of the call to redirect</param>
        /// <param name="options">Call settings. Only Url, Method, FallbackUrl, FallbackMethod, StatusCallback and StatusCallbackMethod properties with values set will be used.</param>
        public virtual Call RedirectCall(string callSid, CallOptions options)
        {
            Require.Argument("CallSid", callSid);
            Require.Argument("Url", options.Url);

            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/Calls/{CallSid}.json";

            request.AddParameter("CallSid", callSid, ParameterType.UrlSegment);
            request.AddParameter("Url", options.Url);
            if (options.Method.HasValue()) request.AddParameter("Method", options.Method);

            if (options.FallbackUrl.HasValue()) request.AddParameter("FallbackUrl", options.FallbackUrl);
            if (options.FallbackMethod.HasValue()) request.AddParameter("FallbackMethod", options.FallbackMethod);

            if (options.StatusCallback.HasValue())
            {
                request.AddParameter("StatusCallback", options.StatusCallback);
                request.AddParameter("StatusCallbackUrl", options.StatusCallback); //workaround for issue DEVX-401
            }
            if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);

            return Execute<Call>(request);
        }
Esempio n. 22
0
        /// <summary>
        /// Redirect a call in progress to a new TwiML URL.  Makes a POST request to a Call Instance resource.
        /// </summary>
        /// <param name="callSid">The Sid of the call to redirect</param>
        /// <param name="redirectUrl">The URL to redirect the call to.</param>
        /// <param name="redirectMethod">The HTTP method to use when requesting the redirectUrl</param>
        public virtual Call RedirectCall(string callSid, string redirectUrl, string redirectMethod)
        {
            Require.Argument("CallSid", callSid);
            Require.Argument("Url", redirectUrl);

            CallOptions options = new CallOptions();
            options.Url = redirectUrl;
            options.Method = redirectMethod;

            return RedirectCall(callSid, options);
        }
 public void Call(CallOptions options)
 {
     _client.InitiateOutboundCall(options);
 }
Esempio n. 24
0
        /// <summary>
        /// Initiates an outgoing twilio call that calls customer phone, redirects to thinq at the time when the customer accepts the call.
        /// </summary>
        /// <returns>call sid if successful, error message otherwise</returns>
        public String call()
        {
            if(!this.isClientValid()) {
                return "Invalid Twilio Account details.";
            }

            try{
                var options = new CallOptions();
                options.Url = TWIML_RESOURCE_URL;
                options.To = this.customer_number;
                options.From = this.twilio_phone_number;
                var call = this.client.InitiateOutboundCall(options);
                return call.Sid;
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Redirect a call in progress to a new TwiML URL.  Makes a POST request to a Call Instance resource.
        /// </summary>
        /// <param name="callSid">The Sid of the call to redirect</param>
        /// <param name="redirectUrl">The URL to redirect the call to.</param>
        /// <param name="redirectMethod">The HTTP method to use when requesting the redirectUrl</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void RedirectCall(string callSid, string redirectUrl, string redirectMethod, Action<Call> callback)
        {
            Require.Argument("CallSid", callSid);
            Require.Argument("Url", redirectUrl);

            CallOptions options = new CallOptions();
            options.Url = redirectUrl;
            options.Method = redirectMethod;

            RedirectCall(callSid, options, callback);
        }
Esempio n. 26
0
        /// <summary>
        /// Redirect a call in progress to a new TwiML URL.  Makes a POST request to a Call Instance resource.
        /// </summary>
        /// <param name="callSid">The Sid of the call to redirect</param>
        /// <param name="redirectUrl">The URL to redirect the call to.</param>
        /// <param name="redirectMethod">The HTTP method to use when requesting the redirectUrl</param>
        public virtual async Task<Call> RedirectCallAsync(string callSid, string redirectUrl, string redirectMethod)
        {
            Require.Argument("CallSid", callSid);
            Require.Argument("Url", redirectUrl);

            CallOptions options = new CallOptions();
            options.Url = redirectUrl;
            options.Method = redirectMethod;

            return await RedirectCallAsync(callSid, options);
        }
Esempio n. 27
0
        protected void ContactBarber_Click(object sender, EventArgs e)
        {
            BindDataList();

            string sql = "SELECT idMembership FROM member WHERE idMember = " + Request.QueryString["id"];
            DataTable dt = Worker.SqlTransaction(sql, connect_string);
            if (dt.Rows.Count > 0)
            {
                if ((dt.Rows[0]["idMembership"].ToString() == "2") || (dt.Rows[0]["idMembership"].ToString() == "1"))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "AddResource('440','415');", true);
                }
                else
                {

                    phoneno = (string)Session["phoneno"];
                    string accountSid = "AC49ecef1b877e244ea13ada1b5fe92b85";
                    //string applicationsid = "AP5556f6cd1af5cfa5317acae7a49eeb5c";
                    string sid = "CA748c6019014ca0ac151908a81299f927";
                    string authToken = "4eeeaf7ed6459dcd02ec7888149d5ea1";
                    string recordingSid = "RE5dabfb2da314b39cd87dc151bf669e78";
                    DateTime datecreated = DateTime.Now;
                    TwilioRestClient client;
                    client = new TwilioRestClient(accountSid, authToken);
                    string APIversuion = client.ApiVersion;
                    string TwilioBaseURL = client.BaseUrl;

                    Account account = client.GetAccount(accountSid);
                    client.GetRecording(recordingSid);
                    client.GetRecordingText(recordingSid);
                    client.ListRecordings(sid, datecreated, 1, 2);
                    client.ListQueues();
                    client.ListIncomingPhoneNumbers();
                    //string Url = "http://demo.twilio.com/Welcome/Call/";
                    String Url = "http://twimlets.com/message";
                    CallOptions options = new CallOptions(); // Set the call From, To, and URL values into a hash map. // This sample uses the sandbox number provided by Twilio // to make the call.
                    options.From = "+14242165015";
                    options.To = phoneno;
                    options.Url = Url; // Place the call.
                    options.Record = true;

                    var call = client.InitiateOutboundCall(options);

                    Session.Remove("phoneno");
                }

            }
        }
Esempio n. 28
0
        private static void AddCallOptions(CallOptions options, RestRequest request)
        {
            request.AddParameter("From", options.From);
            request.AddParameter("To", options.To);

            if (options.ApplicationSid.HasValue())
            {
                request.AddParameter("ApplicationSid", options.ApplicationSid);
            }
            else
            {
                request.AddParameter("Url", options.Url);
            }

            if (options.StatusCallback.HasValue())
            {
                request.AddParameter("StatusCallback", options.StatusCallback);
            }
            if (options.StatusCallbackMethod.HasValue())
            {
                request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);
            }
            if (options.StatusCallbackEvents != null)
            {
                for (int i = 0; i < options.StatusCallbackEvents.Length; i++)
                {
                    request.AddParameter("StatusCallbackEvent", options.StatusCallbackEvents[i]);
                }
            }
            if (options.FallbackUrl.HasValue())
            {
                request.AddParameter("FallbackUrl", options.FallbackUrl);
            }
            if (options.FallbackMethod.HasValue())
            {
                request.AddParameter("FallbackMethod", options.FallbackMethod);
            }
            if (options.Method.HasValue())
            {
                request.AddParameter("Method", options.Method);
            }
            if (options.SendDigits.HasValue())
            {
                request.AddParameter("SendDigits", options.SendDigits);
            }
            if (options.IfMachine.HasValue())
            {
                request.AddParameter("IfMachine", options.IfMachine);
            }
            if (options.Timeout.HasValue)
            {
                request.AddParameter("Timeout", options.Timeout.Value);
            }
            if (options.Record)
            {
                request.AddParameter("Record", "true");
            }
            if (options.SipAuthUsername.HasValue())
            {
                request.AddParameter("SipAuthUsername", options.SipAuthUsername);
            }
            if (options.SipAuthPassword.HasValue())
            {
                request.AddParameter("SipAuthPassword", options.SipAuthPassword);
            }
        }
Esempio n. 29
0
 /// <summary>
 /// Initiates a new phone call. Makes a POST request to the Calls List resource.
 /// </summary>
 /// <param name="options">Call settings. Only properties with values set will be used.</param>
 public IAsyncOperation<Call> InitiateOutboundCallAsync(CallOptions options)
 {
     return (IAsyncOperation<Call>)AsyncInfo.Run((System.Threading.CancellationToken ct) => InitiateOutboundCallAsyncInternal(options));
 }
Esempio n. 30
0
        private async Task<Call> InitiateOutboundCallAsyncInternal(CallOptions options)
        {
            Require.Argument("From", options.From);
            Require.Argument("To", options.To);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallOptions(options, request);

            var result = await ExecuteAsync(request, typeof(Call));
            return (Call)result;

        }
Esempio n. 31
0
        /// <summary>
        /// Redirect a call in progress to a new TwiML URL.  Makes a POST request to a Call Instance resource.
        /// </summary>
        /// <param name="callSid">The Sid of the call to redirect</param>
        /// <param name="options">Call settings. Only Url, Method, FallbackUrl, FallbackMethod, StatusCallback and StatusCallbackMethod properties with values set will be used.</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void RedirectCall(string callSid, CallOptions options, Action<Call> callback)
        {
            Require.Argument("CallSid", callSid);
            Require.Argument("Url", options.Url);

            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/Calls/{CallSid}.json";

            request.AddParameter("CallSid", callSid, ParameterType.UrlSegment);
            request.AddParameter("Url", options.Url);
            if (options.Method.HasValue()) request.AddParameter("Method", options.Method);

            if (options.FallbackUrl.HasValue()) request.AddParameter("FallbackUrl", options.FallbackUrl);
            if (options.FallbackMethod.HasValue()) request.AddParameter("FallbackMethod", options.FallbackMethod);

            if (options.StatusCallback.HasValue())
            {
                request.AddParameter("StatusCallback", options.StatusCallback);
                request.AddParameter("StatusCallbackUrl", options.StatusCallback); //workaround for issue DEVX-401
            }
            if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);

            if (options.RecordingStatusCallback.HasValue())
            {
                request.AddParameter("RecordingStatusCallback", options.RecordingStatusCallback);
            }
            if (options.RecordingStatusCallbackMethod.HasValue())
            {
              request.AddParameter("RecordingStatusCallbackMethod", options.RecordingStatusCallbackMethod);
            }
            if (options.RecordingChannels.HasValue()) request.AddParameter("RecordingChannels", options.RecordingChannels);

            ExecuteAsync<Call>(request, (response) => callback(response));
        }