Enviar un SMS

Para enviar un SMS, sustituya las siguientes variables en el ejemplo siguiente:

ClaveDescripción
VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

VONAGE_BRAND_NAME

The alphanumeric string that represents the name or number of the organization sending the message.

TO_NUMBER

The phone number you are sending the message to.

Escriba el código

Añada lo siguiente a send-sms.sh:

curl -X POST https://rest.nexmo.com/sms/json \
  -u "$VONAGE_API_KEY:$VONAGE_API_SECRET" \
  -d "from=${SMS_SENDER_ID}" \
  -d "to=${SMS_TO_NUMBER}" \
  -d 'text=A text message sent using the Vonage SMS API'

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

sh send-sms.sh

Nota: Para incluir una nueva línea en el mensaje, consulte la documentación de Concatenación y codificación

Pruébalo

Cuando ejecute el ejemplo anterior, el mensaje de texto se enviará al número de móvil que haya especificado.

Para saber más