public void ShouldAddNewIncomingPhoneNumberAsynchronously() { manualResetEvent = new ManualResetEvent(false); var client = new TwilioRestClient(Credentials.TestAccountSid, Credentials.TestAuthToken); PhoneNumberOptions options = new PhoneNumberOptions(); options.PhoneNumber = "+15005550006"; options.VoiceUrl = "http://example.com/phone"; options.VoiceMethod = "GET"; options.VoiceFallbackUrl = "http://example.com/phone"; options.VoiceFallbackMethod = "GET"; options.SmsUrl = "http://example.com/sms"; options.SmsMethod = "GET"; options.SmsFallbackUrl = "http://example.com/sms"; options.SmsFallbackMethod = "GET"; IncomingPhoneNumber result = null; client.AddIncomingPhoneNumber(options, number => { result = number; manualResetEvent.Set(); }); manualResetEvent.WaitOne(); Assert.IsNotNull(result); Assert.IsNull(result.RestException); Assert.IsNotNull(result.Sid); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "{{ account_sid }}"; string AuthToken = "{{ auth_token }}"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var options = new AvailablePhoneNumberListRequest(); options.NearLatLong = "37.840699,-122.461853"; options.Distance = 50; options.Contains = "555"; options.InRegion = "CA"; var result = twilio.ListAvailableLocalPhoneNumbers("US", options); // Purchase the first number in the list var availableNumber = result.AvailablePhoneNumbers[0]; var purchaseOptions = new PhoneNumberOptions(); purchaseOptions.PhoneNumber = availableNumber.PhoneNumber; var number = twilio.AddIncomingPhoneNumber(purchaseOptions); Console.WriteLine(number.Sid); }
/// <summary> /// Procures the number. /// </summary> /// <param name="phoneNumber">The phone number.</param> public string ProcureNumber(string phoneNumber) { var number = _twilio.AddIncomingPhoneNumber(new PhoneNumberOptions { PhoneNumber = phoneNumber, SmsMethod = "POST", SmsUrl = "http://dj.3cjr.com/api/receivemessage" }); return(number.Sid); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "{{ account_sid }}"; string AuthToken = "{{ auth_token }}"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var options = new PhoneNumberOptions(); options.PhoneNumber = "33"; var number = twilio.AddIncomingPhoneNumber(options); Console.WriteLine(number.Sid); }
public VoipPhone BuyNumber(string phoneNumber) { var newNumber = client.AddIncomingPhoneNumber( new PhoneNumberOptions { AccountSid = accountSid, PhoneNumber = phoneNumber }); ThrowIfError(newNumber); return(new VoipPhone { Id = newNumber.Sid, Number = phoneNumber.Substring(1) }); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var options = new PhoneNumberOptions(); options.VoiceUrl = "http://demo.twilio.com/docs/voice.xml"; options.PhoneNumber = "+15005550006"; var number = twilio.AddIncomingPhoneNumber(options); Console.WriteLine(number.Sid); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "{{ account_sid }}"; string AuthToken = "{{ auth_token }}"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var options = new PhoneNumberOptions(); options.FriendlyName = "My Company Line"; options.VoiceUrl = "http://demo.twilio.com/docs/voice.xml"; options.PhoneNumber = "+15105647903"; options.VoiceMethod = "GET"; var number = twilio.AddIncomingPhoneNumber(options); Console.WriteLine(number.Sid); }
public ActionResult Buy(string PhoneNumber) { var accountSid = ConfigurationManager.AppSettings["TwilioAccountSid"]; var authToken = ConfigurationManager.AppSettings["TwilioAuthToken"]; var twilio = new TwilioRestClient(accountSid, authToken); var purchaseOptions = new PhoneNumberOptions { PhoneNumber = PhoneNumber }; var purchase = twilio.AddIncomingPhoneNumber(purchaseOptions); if (purchase.RestException != null) { return(new HttpStatusCodeResult(500, purchase.RestException.Message)); } return(RedirectToAction("Index", "Numbers", new { number = PhoneNumber })); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "{{ account_sid }}"; string AuthToken = "{{ auth_token }}"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var result = twilio.ListAvailableMobilePhoneNumbers("GB"); // Purchase the first number in the list var availableNumber = result.AvailablePhoneNumbers[0]; var purchaseOptions = new PhoneNumberOptions(); purchaseOptions.PhoneNumber = availableNumber.PhoneNumber; var number = twilio.AddIncomingPhoneNumber(purchaseOptions); Console.WriteLine(number.Sid); }
public void ShouldAddNewIncomingPhoneNumberByAreaCode() { var client = new TwilioRestClient(Credentials.TestAccountSid, Credentials.TestAuthToken); PhoneNumberOptions options = new PhoneNumberOptions(); options.AreaCode = "500"; options.VoiceUrl = "http://example.com/phone"; options.VoiceMethod = "GET"; options.VoiceFallbackUrl = "http://example.com/phone"; options.VoiceFallbackMethod = "GET"; options.SmsUrl = "http://example.com/sms"; options.SmsMethod = "GET"; options.SmsFallbackUrl = "http://example.com/sms"; options.SmsFallbackMethod = "GET"; var result = client.AddIncomingPhoneNumber(options); Assert.IsNotNull(result); Assert.IsNull(result.RestException); Assert.IsNotNull(result.Sid); }
public bool BuyNumberFromAreaCode(string areacode) { var client = new TwilioRestClient(_accountSid, _authToken); var incoming = client.AddIncomingPhoneNumber( new PhoneNumberOptions() { AreaCode = areacode, VoiceUrl = "http://example.com/Call" }); if (incoming.RestException != null) { //TODO: Log an error return(false); } else { this.PhoneNumber = incoming.PhoneNumber; return(true); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var options = new AvailablePhoneNumberListRequest(); options.InRegion = "AR"; var result = twilio.ListAvailableLocalPhoneNumbers("US", options); // Purchase the first number on the list var availableNumber = result.AvailablePhoneNumbers[0]; var purchaseOptions = new PhoneNumberOptions(); purchaseOptions.PhoneNumber = availableNumber.PhoneNumber; var number = twilio.AddIncomingPhoneNumber(purchaseOptions); Console.WriteLine(number.Sid); }