Enviar un SMS con Unicode

La SMS API de Vonage también admite caracteres Unicode, que deberás usar cuando te comuniques con clientes en chino, japonés y coreano.

Para enviar un SMS que contenga caracteres Unicode, 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-an-sms-with-unicode.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=こんにちは世界' \
  -d 'type=unicode'

Ver fuente completa

Ejecute su código

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

sh send-an-sms-with-unicode.sh

Pruébalo

Cuando ejecute el ejemplo anterior, el mensaje de texto se enviará al número de móvil especificado con los caracteres Unicode intactos.

Tenga en cuenta que los mensajes Unicode sólo pueden contener 70 caracteres, en lugar de los 160 habituales. Hay más información al respecto en la página de ayuda

Para saber más