送信RCSメッセージを取り消す
このコード・スニペットでは、RCSを送信する方法を学ぶ。 file メッセージAPIを使用する。
- RCSメッセージングの詳細については RCSメッセージングを理解する
例
各コード・スニペットで使用されているすべての変数の説明を以下に示します:
| キー | 説明 |
|---|---|
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 |
JWT | Used to authenticate your request. See Authentication for more information, including how to generate a JWT. |
MESSAGE_UUID | The UUID of the specific message. |
注: ベースURIは、取り消されるメッセージの地域固有でなければならない。
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
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.
Create a file named revoke-message.js and add the following code:
const { Vonage } = require('@vonage/server-sdk');
/**
* It is best to send messages using JWT instead of basic auth. If you leave out
* apiKey and apiSecret, the messages SDK will send requests using JWT tokens
*
* @link https://developer.vonage.com/en/messages/technical-details#authentication
*/
const vonage = new Vonage(
{
applicationId: VONAGE_APPLICATION_ID,
privateKey: VONAGE_PRIVATE_KEY,
},
{
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}),
},
);Write the code
Add the following to revoke-message.js:
vonage.messages.updateMessage(MESSAGE_ID, 'revoked')
.then(() => console.log('Message revoked'))
.catch((error) => console.error(error));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 RevokeMessage 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.rcs with the package containing RevokeMessage:
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 RevokeMessage and add the following code to the main method:
VonageClient client = VonageClient.builder()
.applicationId(VONAGE_APPLICATION_ID)
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
.build();Write the code
Add the following to the main method of the RevokeMessage class:
client.getMessagesClient().revokeOutboundMessage(MESSAGES_MESSAGE_ID, MESSAGES_GEOSPECIFIC_API_HOST);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.rcs with the package containing RevokeMessage:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Create a file named revoke-message.php and add the following code:
$keypair = new \Vonage\Client\Credentials\Keypair(
file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH),
VONAGE_APPLICATION_ID
);
$client = new \Vonage\Client($keypair);Write the code
Add the following to revoke-message.php:
$messageUuid = '1a5737ad-efd8-4efb-8edd-70d5b8b4ada7';
$client->messages()->updateRcsStatus($messageUuid, \Vonage\Messages\Client::RCS_STATUS_REVOKED);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.
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.
Create a file named revoke-message.rb and add the following code:
Run your code
Save this file to your machine and run it:
試してみる
コードを実行すると、送信メッセージを取り消すリクエストが行われる。