Verifyリクエストの検索【非推奨
検索機能を使って、Verifyリクエストの現在のステータスや最終的な結果を見ることができます。 request_id Verifyコードが送信されたときに返される。
サンプルコードの以下の変数を、独自の値に置き換えてください:
| キー | 説明 |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on |
VONAGE_API_SECRET | Your Vonage API secret (also available on |
REQUEST_ID | The ID of the Verify request (this is returned in the API response when you |
コードを実行する
このファイルをあなたのマシンに保存し、実行する:
前提条件
build.gradle に以下を追加する:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'SearchVerification という名前のファイルを作成し、main メソッドに以下のコードを追加する:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}コードを書く
SearchVerification ファイルのmain メソッドに以下を追加する:
val response = client.verifyLegacy.request(VERIFY_REQUEST_ID).info()
if (response.status == VerifyStatus.OK) {
response.verificationRequests.forEach {
println(it)
}
}コードを実行する
Gradle用のアプリケーション プラグインを使うことで、アプリケーションの実行を簡単にすることができます。build.gradle を以下のように更新する:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''以下のgradle コマンドを実行し、com.vonage.quickstart.kt.verify.legacy をSearchVerification を含むパッケージに置き換えてアプリケーションを実行する:
前提条件
build.gradle に以下を追加する:
implementation 'com.vonage:server-sdk:9.3.1'SearchVerification という名前のファイルを作成し、main メソッドに以下のコードを追加する:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();コードを書く
SearchVerification ファイルのmain メソッドに以下を追加する:
SearchVerifyResponse response = client.getVerifyClient().search(VERIFY_REQUEST_ID);
if (response.getStatus() == VerifyStatus.OK) {
response.getVerificationRequests().forEach(it -> {
System.out.println(it.getRequestId() + " " + it.getStatus());
});
}コードを実行する
Gradle用のアプリケーション プラグインを使うことで、アプリケーションの実行を簡単にすることができます。build.gradle を以下のように更新する:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''以下のgradle コマンドを実行し、com.vonage.quickstart.verify をSearchVerification を含むパッケージに置き換えてアプリケーションを実行する:
前提条件
コードを書く
SearchVerificationRequest.cs に以下を追加する:
var request = new VerifySearchRequest() { RequestId = requestId };前提条件
composer require vonage/clientsearch.php という名前のファイルを作成し、以下のコードを追加する:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));コードを書く
search.php に以下を追加する:
try {
$result = $client->verify()->search(REQUEST_ID);
echo "Request has a status of " . $result->getStatus() . PHP_EOL;
} catch (\Vonage\Client\Exception\Request $e) {
error_log("Client error: " . $e->getMessage());
exit(1);
} catch (\Vonage\Client\Exception\Server $e) {
error_log("Server error: " . $e->getMessage());
exit(1);
}コードを実行する
このファイルをあなたのマシンに保存し、実行する:
前提条件
pip install vonage python-dotenvコードを書く
search.py に以下を追加する:
from vonage import Auth, Vonage
from vonage_verify_legacy import VerifyStatus
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
response: VerifyStatus = client.verify_legacy.search(VERIFY_REQUEST_ID)
print(response)コードを実行する
このファイルをあなたのマシンに保存し、実行する: