受信メッセージを既読にする
このコードスニペットでは、WhatsApp 受信メッセージを read.メッセージを read をクリックすると、WhatsApp UIでそのメッセージに青いチェックマークが表示されます。
受信メッセージを既読にするには PATCH リクエストは、Vonage のサーバーに保存されているメッセージ・オブジェクトへのもので、UUID によって特定のメッセージを識別します。メッセージ・オブジェクトは地理的に配置されているので、リクエストには地理的な URL を使用する必要があります。 read.
重要: メッセージ未送信の場合、WhatsAppは初回メッセージ送信時にテンプレートを要求します。詳しくは WhatsAppトピックの理解.
例
各コード・スニペットで使用されているすべての変数の説明を以下に示します:
| キー | 説明 |
|---|---|
JWT | Used to authenticate your request. See Authentication for more information, including how to generate a JWT. |
VONAGE_APPLICATION_ID | The Vonage Application ID. |
VONAGE_PRIVATE_KEY_PATH | Private key path. |
GEOSPECIFIC_MESSAGES_API_URL | The URL for the Geo-specific Messages API endpoint. One of |
GEOSPECIFIC_VONAGE_API_HOST | The hostname for the Geo-specific API endpoint. One of |
MESSAGE_UUID | The UUID of the specific message. |
注: 先頭の + または 00 電話番号を入力する場合は、447700900000のように国番号から入力してください。
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Write the code
Add the following to mark-as-read.sh:
curl -X PATCH "${GEOSPECIFIC_MESSAGES_API_URL}/${MESSAGES_MESSAGE_ID}" \
-H "Authorization: Bearer "$JWT\
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"status": "read",
}'
Run your code
Save this file to your machine and run it:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Add the following to build.gradle:
Create a class named MarkAsRead 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.messages.whatsapp with the package containing MarkAsRead:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Add the following to build.gradle:
Create a class named MarkAsRead 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.messages.whatsapp with the package containing MarkAsRead:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Install-Package VonagePrerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
composer require vonage/clientCreate a file named send-file.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
pip install vonage python-dotenvRun your code
Save this file to your machine and run it:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
gem install vonageCreate a file named mark-as-read.rb and add the following code:
Run your code
Save this file to your machine and run it:
試してみる
コードを実行すると、指定された受信メッセージを既読にするリクエストが行われる。