コード例 #1
0
ファイル: AlertAll.cs プロジェクト: looyvillelarry/nadtalert
        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));
        }
コード例 #2
0
 public BlobService(StorageCreds creds)
 {
     this.creds = creds ?? throw new System.ArgumentNullException(nameof(creds));
 }