0

I'm new to sh, I apologize if it's a really dumb question. I'm trying to develop a script to communicate with an SMS sending API.

The code is as follows:

#!/bin/bash
TEXTO='MENSAGEM'
NUM="41999999999"
url="https://api.smsdev.com.br/v1/send?key=KEY&type=9&number"

curl -G --data-urlencode "msg=$TEXTO" --request GET --url "$url=$NUM"

With a single number in the parameter (NUM), it works normally. However I would like to insert more numbers. The API only accepts one number per request, would it be possible to make the script make a request for each number?

Thank you very much in advance! :)

1 Answers1

0

Assuming you want to send the same message to multiple numbers, you could do it like this:

#!/bin/bash
TEXTO="MENSAGEM"
URL="https://api.smsdev.com.br/v1/send?key=KEY&type=9&number"
NUMBERS=("41999999999", "1234567890", "84737562823")

for number in "${NUMBERS[@]}"; do
    curl -G --data-urlencode "msg=$TEXTO" --request GET --url "$URL=$number"
done
Fonic
  • 2,625
  • 23
  • 20