Vonage SMS APIを始めるにあたって
ショートメッセージサービス(SMS)は、標準化された通信プロトコルを使用して、短いテキストメッセージをデバイス間またはデバイスに送信するテキストメッセージングサービスである。これらのメッセージは携帯電話ネットワークを介して送信される。
VonageのMessages APIのような通信APIでは、APIエンドポイントにHTTPリクエストを行うことで、プログラムでSMSメッセージを送信することができます。メッセージはその後、受信者のデバイスに配信するために携帯電話ネットワークにダウンストリームに渡されます。
Messages APIとSMS API
現在、SMSメッセージを送信できるVonage APIは2つあります:
- について Messages API
- について SMS API
この2つのAPIにはいくつかの違いがあり、どちらを使うかを決める際に考慮するとよいだろう。
Messages API
- Messages APIはマルチチャネル・メッセージングAPIで、SMSだけでなく他のメッセージング・チャネルもサポートしている。
- これには、MMSやRCSなどのネットワークベースのチャネルや、WhatsAppやFacebook MessengerなどのOTTチャネルも含まれます。
- すべてのチャンネルは同じエンドポイントを使用し、リクエストペイロードの基本構造も同じなので、1つの統合で複数のチャンネルを使用することができます。
- Messages APIは、新機能の追加やネットワークベースおよびOTTチャンネルのサポートなど、今後も強化される予定です。
- Messages API は、以下のステータスをサポートする Messages Status webhook を提供します:
submitteddeliveredrejectedundeliverable
SMS API
- SMS APIは、高スループット(例:500メッセージ/秒以上)のユースケースに適しています(スループット・レベルの向上はご要望に応じます)。
- SMS APIは以下の機能を提供します。 HIPAAコンプライアンス
- SMS APIは以下の機能を提供します。 領収書 個々のメッセージセグメント(長いメッセージが配信のために複数の部分に分割されている場合)。
- SMS API 領収書 は以下のステータスをサポートしている:
accepteddeliveredbufferedexpiredfailedrejectedunknown
10桁の地理的電話番号を使用して米国でSMSを送信するお客様は、10 DLC規制ガイドラインに従う必要があります。詳しくは 10 DLCドキュメンテーション をご覧ください。
SMSを送信する
この例では、選択した番号にSMSを送信する方法を示します。
この例は、特に SMS API で使用するためのものです。
まず最初に、 Vonageアカウントに申し込む まだ持っていない場合は、APIキーとシークレットを ダッシュボードのスタートページ.
サンプルコードの以下のプレースホルダーの値を置き換えてください:
| キー | 説明 |
|---|---|
VONAGE_API_KEY | Vonage APIキー。 |
VONAGE_API_SECRET | あなたのVonage APIシークレット。 |
Run your code
Save this file to your machine and run it:
Prerequisites
Create a file named send.js and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
Create a class named SendMessage and add the following code to the main method:
Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.sms with the package containing SendMessage:
Prerequisites
Add the following to build.gradle:
Create a class named SendMessage and add the following code to the main method:
Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.sms with the package containing SendMessage:
Prerequisites
Create a file named SendSms.cs and add the following code:
using Vonage;
using Vonage.Request;Add the following to SendSms.cs:
Prerequisites
Create a file named send-sms.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
Run your code
Save this file to your machine and run it:
Prerequisites
Create a file named send.rb and add the following code:
Run your code
Save this file to your machine and run it:
トラブルシューティング
APIコールの際に問題が発生した場合は、返される ステータスフィールド 具体的には エラーコード.
重要だ: 米国のお客様がSMS APIを使用して+1国コード10桁ロングコード(10 DLC)から米国のネットワークにトラフィックを送信する場合、送信の承認を得るためにブランドとキャンペーンを登録する必要があります。承認後、キャンペーンに番号をリンクする必要があります。詳しくは 10 DLCサポートセクション.
Vonage SMS APIコンセプト
Vonage SMS API を使用する前に、以下の内容をよく理解してください:
Numbersフォーマット - SMS APIにはE.164形式の電話番号が必要です。
認証 - SMS APIは、アカウントのAPIキーとシークレットを使用して認証します。
ウェブフック - SMS APIは、アプリケーションのウェブサーバーにHTTPリクエストを送信します。例えば、SMSの受信や配信の受信などです。