検証コードを確認する
ユーザーが入力した認証コードを確認します。認証コードは request_id を受信した。 検証コードが送信された.
注:常に 認証コードを確認する その後 送信.これにより、Vonageは成功したリクエストの数と 不正使用からの保護 プラットフォームの
サンプルコードの以下の変数を、独自の値に置き換えてください:
| キー | 説明 |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
REQUEST_ID | The ID of the Verify request (this is returned in the API response when you send a verification code) |
CODE | The code the user supplies as having been sent to them |
Write the code
Add the following to send-verification-code.sh:
curl GET "https://api.nexmo.com/verify/check/json?api_key=$VONAGE_API_KEY&api_secret=$VONAGE_API_SECRET&request_id=$VERIFY_REQUEST_ID&code=$VERIFY_CODE"Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
Create a class named CheckVerification 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.verify.legacy with the package containing CheckVerification:
Prerequisites
Add the following to build.gradle:
Create a class named CheckVerification and add the following code to the main method:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Write the code
Add the following to the main method of the CheckVerification class:
CheckResponse response = client.getVerifyClient().check(VERIFY_REQUEST_ID, VERIFY_CODE);
if (response.getStatus() == VerifyStatus.OK) {
System.out.println("Verification Successful");
}
else {
System.out.println("Verification failed: " + response.getErrorText());
}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.verify with the package containing CheckVerification:
Prerequisites
Install-Package VonageCreate a file named CheckVerificationRequest.cs and add the following code:
using Vonage;
using Vonage.Request;
using Vonage.Verify;Add the following to CheckVerificationRequest.cs:
var credentials = Credentials.FromApiKeyAndSecret(vonageApiKey, vonageApiSecret);Write the code
Add the following to CheckVerificationRequest.cs:
var request = new VerifyCheckRequest() { Code = code, RequestId = requestId };Prerequisites
composer require vonage/clientCreate a file named verify.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvRun your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named check.rb and add the following code:
Run your code
Save this file to your machine and run it: