static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var validationRequest = ValidationRequestResource.Create( phoneNumber: new Twilio.Types.PhoneNumber("+15017122661") ); Console.WriteLine(validationRequest.FriendlyName); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"friendly_name\": \"friendly_name\",\"phone_number\": \"+18001234567\",\"validation_code\": 100}" )); var response = ValidationRequestResource.Create(new Twilio.Types.PhoneNumber("+987654321"), client: twilioRestClient); Assert.NotNull(response); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var phoneNumber = new PhoneNumber("+12349013030"); var validationRequest = ValidationRequestResource.Create( phoneNumber, friendlyName: "My Home Phone Number"); Console.WriteLine(validationRequest.ValidationCode); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var validationRequest = ValidationRequestResource.Create( friendlyName: "My Home Phone Number", phoneNumber: new Twilio.Types.PhoneNumber("+14158675310") ); Console.WriteLine(validationRequest.FriendlyName); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var phoneNumber = new PhoneNumber("+12349013030"); var validationRequest = ValidationRequestResource.Create( phoneNumber, friendlyName: "My Home Phone Number"); Console.WriteLine(validationRequest.ValidationCode); }
public static bool CreateNumber(string Number) { try { var twilio = TDSettings.DefaultTwilio(); Twilio.TwilioClient.Init(twilio.ID, twilio.Key); var phoneNumber = new PhoneNumber(Number); //var tw = new TwilioRestClient(twilio.ID, twilio.Key); //var callerId = tw..AddOutgoingCallerId("+14158675309", "My Home Phone Number", null, null); var validationRequest = ValidationRequestResource.Create( phoneNumber, friendlyName: "Auto AddNumber"); Console.WriteLine(validationRequest.ValidationCode); } catch { } return(true); }
public IActionResult Create(Contact contact) { const string accountSid = "ACbdad9a7a5b65ad655c501ef37ee0375f"; const string authToken = "ac924cd3e5aca5f62680c3f4f0e16721"; TwilioClient.Init(accountSid, authToken); var phoneNumber = new PhoneNumber(contact.Number); var validationRequest = ValidationRequestResource.Create( phoneNumber, friendlyName: contact.Name); var myValidation = (validationRequest.ValidationCode); db.Add(contact); db.SaveChanges(); return(Json(myValidation)); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Api, "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json", "" ); request.AddPostParam("PhoneNumber", Serialize(new Twilio.Types.PhoneNumber("+987654321"))); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { ValidationRequestResource.Create(new Twilio.Types.PhoneNumber("+987654321"), client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public void VerifyCallerID() { PrintBanner(); Console.WriteLine("Please enter the name of the number that Hxngry will be using. (Mike's Phone, John's iPhone, Mary, etc)"); var numName = Console.ReadLine(); var validationRequest = ValidationRequestResource.Create( friendlyName: numName, phoneNumber: new Twilio.Types.PhoneNumber(this.user.Phone) ); Console.WriteLine("You will receive a call within the next minute, the call will request a verification code.\n"); Console.WriteLine("This is your verification code: " + validationRequest.ValidationCode); Console.WriteLine("Once you have entered the verification code you may press any key to continue..."); AppLoading(); PrintBanner(); Console.WriteLine("You will now be sent an SMS message verifying your number's authentication."); var message = MessageResource.Create( body: "Number verified.", from: new Twilio.Types.PhoneNumber("+15204629326"), to: new Twilio.Types.PhoneNumber(this.user.Phone) ); }