static void Main(string[] args) { // Init a TwilioAccount object. Get Sid, authToken, and set fromNumber TwilioAccount twilioAccount = new TwilioAccount(); twilioAccount.GetSidAndAuthToken(FilePath); twilioAccount.SetFromNumber(FilePath); TwilioClient.Init(twilioAccount.AccountSid, twilioAccount.AuthToken); // Ask user for the number and message content Console.WriteLine("Quick and dirty test of Twilio"); Console.WriteLine("Enter a message: "); string msgContent = Console.ReadLine(); Console.WriteLine("Message entered: " + msgContent); Console.WriteLine("Enter phone#: "); string phoneNumber = Console.ReadLine(); Console.WriteLine("Phone# entered: " + msgContent); // Send message twilioAccount.SendMessage(msgContent, phoneNumber); // Exit Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }
// Your TwilioAccount is set up in the Startup.cs file public HomeController(IOptions <TwilioAccount> options) { if (options == null) { throw new ArgumentException(nameof(options)); } _twilioAccount = options.Value; }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { //log.LogInformation("Alert All function called"); string messageText = req.Query["message"]; if (string.IsNullOrWhiteSpace(messageText)) { messageText = "PRN ALERT : CHECK ZELLO !"; } //string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); //dynamic data = JsonConvert.DeserializeObject(requestBody); var storageCreds = new StorageCreds { Account = storageAccount, Key = storageAccountKey }; var blobService = new BlobService(storageCreds); var twilioAccount = new TwilioAccount { AccountSid = twilioAccountSid, AuthToken = twilioAccountKey }; //var authenticationService = new AuthenticationService(twilioAuthServiceKey); //var textToSpeechService = new TextToSpeechService(authenticationService,storageCreds); TwilioClient.Init(twilioAccount.AccountSid, twilioAccount.AuthToken); int counter = 1; /* TwilioResponse twilioResponse = new TwilioResponse(); * await CallResource.CreateAsync( * to: new PhoneNumber ("+15027516471"), * from: new PhoneNumber(twilioFrom), * url: new Uri($"{siteUrl}/api/speech/call/{twilioResponse.MessageSid}"), * method: "GET"); * ) * await this.Call() */ foreach (var person in await blobService.GetPhoneNumbersAsync()) { var message = MessageResource.Create( body: messageText, from: new Twilio.Types.PhoneNumber(twilioFromNumber), to: new Twilio.Types.PhoneNumber(person) ); counter++; } string responseMessage = $"A message of {messageText} was sent to {counter-1} people."; return(new OkObjectResult(responseMessage)); }
public async Task <IActionResult> Create(TwilioAccount twilioAccount) { if (ModelState.IsValid) { _context.Add(twilioAccount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id", landlord.IdentityUserId); return(View(twilioAccount)); }
public ActionResult Index() { try { var lib = new TwilioAccount().GetAccount(); } catch (Exception ex) { throw new HttpException(); } return(View()); }
public TwilioService(IOptions <TwilioAccount> options, ILogger logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); if (options == null) { throw new ArgumentException(nameof(options)); } _twilioAccount = options.Value; TwilioClient.Init( _twilioAccount.AccountSid, _twilioAccount.AuthToken ); }
public void Setup() { _twilioAccount = new TwilioAccount { AuthToken = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", ApiKey = "SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", ApiSecret = "aXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", ChatServiceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", NotificationServiceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", SyncServiceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; var options = Options.Create(_twilioAccount); _sut = new UtilitiesController(options); }
public TwilioController(IOptions <TwilioAccount> account, ITokenGenerator tokenGenerator) { _account = account.Value; _tokenGenerator = tokenGenerator; //if (_account.SyncServiceSid == String.Empty) //{ _account.SyncServiceSid = "default"; //} TwilioClient.Init( _account.ApiKey, _account.ApiSecret, _account.AccountSid ); ProvisionSyncDefaultService(_account.SyncServiceSid); }
public IActionResult SendSms(string phone, string userId) { var twilioAcc = new TwilioAccount(); Configuration.GetSection("Twilio").Bind(twilioAcc); var accountSid = twilioAcc.Sid; var authToken = twilioAcc.Token; TwilioClient.Init(accountSid, authToken); var to = new PhoneNumber($"+1{phone}"); var from = new PhoneNumber("+12057402552"); var message = MessageResource.Create(to: to, from: from, body: "Its time to check your blood sugar!"); return(RedirectToAction("Index", "Data")); }
public UtilitiesController(IOptions <TwilioAccount> twilioAccount) { if (twilioAccount == null) { throw new ArgumentNullException(nameof(twilioAccount)); } _twilioAccount = twilioAccount.Value; // if the Sync Service SID is blank, use the default Sync Service instead if (_twilioAccount.SyncServiceSid == string.Empty) { _twilioAccount.SyncServiceSid = "default"; } TwilioClient.Init( _twilioAccount.ApiKey, _twilioAccount.ApiSecret, _twilioAccount.AccountSid ); // Ensure that the Sync Default Service is provisioned ProvisionSyncDefaultService(_twilioAccount.SyncServiceSid); }
public CompletedNotificationRule(IOptions <TwilioAccount> account) { _twilioAccount = account.Value ?? throw new ArgumentNullException(nameof(account)); }
public IActionResult Create() { var twilioAccount = new TwilioAccount(); return(View(twilioAccount)); }
public MessagingService(IOptions <TwilioAccount> account) { _account = account.Value ?? throw new ArgumentNullException(); }
public TokenGenerator(IOptions <TwilioAccount> account) { _account = account.Value; }
public HomeController(IOptions <TwilioAccount> twilioAccount) { _twilioAccount = twilioAccount.Value ?? throw new ArgumentException(nameof(twilioAccount)); }
public MessagingService(IOptions <TwilioAccount> twilioAccount) { _twilioAccount = twilioAccount.Value ?? throw new ArgumentNullException(nameof(twilioAccount)); }