ユニコードでSMSを送信する

Vonage SMS APIはUnicode文字もサポートしており、中国語、日本語、韓国語の顧客とのコミュニケーションに必要です。

ユニコード文字を含むSMSを送信するには、以下の例で以下の変数を置き換えてください:

キー説明
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.

Write the code

Add the following to 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'

View full source

Run your code

Save this file to your machine and run it:

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

試してみる

上の例を実行すると、テキスト・メッセージはUnicode文字そのままで、指定された携帯電話番号に送信されます。

ユニコード・メッセージには通常の160文字ではなく、70文字しか含めることができないことに注意してください。これについては ヘルプページ

さらに読む