領収書

Vonage SMS APIを使用して送信したメッセージが顧客に届いたかどうかを確認するには、以下のリクエストを行ってください。 納品書 キャリアから

注: すべてのネットワークや国が配送受領書をサポートしているわけではありません。詳しくはナレッジベースをご覧ください。 を受けるかもしれない。 ネットワークが領収書をサポートしていない場合。領収書の詳細については ドキュメンテーション.

領収書にアクセスするには、以下の手順が必要です:

注: メッセージを送信した後、配信レシートを受け取るまでに時間がかかる場合があります。

Prerequisites

Add the following to build.gradle:

implementation 'com.vonage:server-sdk-kotlin:2.1.1'
implementation 'io.ktor:ktor-server-netty'
implementation 'io.ktor:ktor-serialization-jackson'

Write the code

Add the following to the main method of the ReceiveSmsDlr class:

embeddedServer(Netty, port = 8000) {
    routing {
        route("/webhooks/delivery-receipt") {
            handle {
                if (call.request.queryParameters.isEmpty()) {
                    val json = call.receive<String>()
                    println(json)
                }
                else {
                    call.request.queryParameters.forEach { key, values ->
                        println("$key: ${values.first()}")
                    }
                }
                call.respond(HttpStatusCode.NoContent)
            }
        }
    }
}.start(wait = true)

View full source

Run your code

We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:

apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''

Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.sms with the package containing ReceiveSmsDlr:

gradle run -Pmain=com.vonage.quickstart.kt.sms.ReceiveSmsDlr

Vonage DashboardでWebhookエンドポイントを設定します。

VonageがWebhookにアクセスする方法を知るには、Vonageアカウントで設定する必要があります。

コード・スニペットでは、ウェブフックは次の場所にあります。 /webhooks/delivery-receipt.Ngrok を使用している場合、Webhook を設定する必要があります。 Vonage Dashboard API 設定ページ という形式である。 https://demo.ngrok.io/webhooks/delivery-receipt.交換 demo というフィールドにエンドポイントを入力します。 配信レシートのWebhook URL:

試してみる

メッセージを送る を携帯電話番号に送信すると、ネットワークがサポートしている場合は、以下の形式で配信レシートを受け取ることができます:

{
  "err-code": "0",
  "message-timestamp": "2020-10-25 12:10:29",
  "messageId": "0B00000127FDBC63",
  "msisdn": "447700900000",
  "network-code": "23410",
  "price": "0.03330000",
  "scts": "1810251310",
  "status": "delivered",
  "to": "Vonage"
}

注: メッセージを送信した後、配信レシートを受け取るまでに時間がかかる場合があります。

詳細情報