Numbersインサイトアドバンス
2027年2月4日をもって、VonageはVonage Number Insightsを終了いたします。継続的なサポートを確保し、よりスケーラブルで将来性のあるソリューションを提供するため、当社の強化されたソリューションへの移行をお勧めします: Vonage Identity Insights API.Vonage Identity Insight APIは、複数の電話番号関連データセットを1つの柔軟なAPIに統合し、電話番号に関するリアルタイムの情報を要求したり、番号のフォーマット、キャリアの詳細、SIMスワップ、加入者照合などのインサイトを1回の呼び出しで自由に組み合わせて取得できるようにします。
をご確認ください。 Numbersインサイト移行ガイドAPIの相違点、必要な変更点、スムーズな移行のためのベストプラクティスに関する詳細なガイダンスを提供しています。
Number Insight Advanced APIは、以下のすべてのデータを提供します。 Numbers Insight 標準 API 以下の追加情報とともに:
- Numbersが有効である可能性が高い場合
- ポート番号の場合
- 番号に到達可能な場合(米国では利用不可)
- 番号がローミングかどうか、ローミングの場合はキャリアと国名
この情報を使って、Numbersに関連するリスクを判断する。
なお、Advanced APIでは、固定電話に関する以下のような追加情報は提供されません。 Numbers Insight 標準 API.固定電話番号に関する洞察については、Standard APIをご利用ください。
このコード・スニペットは 非同期 をNumber Insight APIに呼び出す。 これがVonageの推奨するアプローチです。.オプションで、Number Insight Advanced APIを使用できます。 同期的にただし、同期的な使用はタイムアウトを引き起こす可能性があるので注意すること。
コード例を実行する前に、変数のプレースホルダーを置き換えてください:
| キー | 説明 |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
INSIGHT_NUMBER | The number you want to retrieve insight information for. |
Write the code
Add the following to ni-advanced-async.sh:
curl "https://api.nexmo.com/ni/advanced/async/json?api_key=$VONAGE_API_KEY&api_secret=$VONAGE_API_SECRET&number=$INSIGHT_NUMBER&callback=$INSIGHT_CALLBACK_URL"
Run your code
Save this file to your machine and run it:
Prerequisites
npm install express body-parserWrite the code
Add the following to ni-advanced-async-client.js:
const app = require('express')();
const bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true,
}));
const handleInsight = (request, response) => {
console.log('params', Object.assign(request.query, request.body));
response.status(204).send();
};
app.post('/webhooks/insight', handleInsight);
app.listen(3000);Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a class named AdvancedInsightAsync and add the following code to the main method:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Write the code
Add the following to the main method of the AdvancedInsightAsync class:
client.numberInsight.advancedAsync(INSIGHT_NUMBER, INSIGHT_CALLBACK_URL)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.numberinsight with the package containing AdvancedInsightAsync:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a class named AdvancedInsightAsync 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 AdvancedInsightAsync class:
var response = client.getInsightClient().getAdvancedAsyncNumberInsight(
AdvancedInsightAsyncRequest.builder()
.number(INSIGHT_NUMBER)
.callback(INSIGHT_CALLBACK_URL)
.build()
);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.insight with the package containing AdvancedInsightAsync:
Prerequisites
Install-Package VonageCreate a file named AdvancedAsync.cs and add the following code:
using Vonage;
using Vonage.Request;
using Vonage.NumberInsights;Add the following to AdvancedAsync.cs:
var creds = Credentials.FromApiKeyAndSecret(VONAGE_API_KEY, VONAGE_API_SECRET);Write the code
Add the following to AdvancedAsync.cs:
var request = new AdvancedNumberInsightAsynchronousRequest() { Number = INSIGHT_NUMBER, Callback = INSIGHT_CALLBACK_URL };Prerequisites
composer require vonage/clientCreate a file named advanced-async-trigger.php and add the following code:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client($basic);Write the code
Add the following to advanced-async-trigger.php:
try {
$client->insights()->advancedAsync(SEARCH_NUMBER, CALLBACK_WEBHOOK);
echo "The number will be looked up soon.";
} 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);
}Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvWrite the code
Add the following to ni-advanced-async-trigger.py:
from vonage import Auth, Vonage
from vonage_number_insight import (AdvancedAsyncInsightRequest,
AdvancedAsyncInsightResponse)
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
insight: AdvancedAsyncInsightResponse = client.number_insight.get_advanced_info_async(
AdvancedAsyncInsightRequest(number=INSIGHT_NUMBER, callback=INSIGHT_CALLBACK_URL)
)
pprint(insight)Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named ni-advanced-async-client.rb and add the following code:
Run your code
Save this file to your machine and run it:
APIは以下の情報をクライアントに返すことで、リクエストを承認する:
{
"request_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"number": "447700900000",
"remaining_balance": "10.000000",
"request_price": "0.03000000",
"status": 0
}
データが利用可能になると、指定したウェブフックに POST リクエストをご覧ください。を参照のこと。 Numbers Insight アドバンスド非同期コールバック のコード・スニペットで、Webhookハンドラのコーディング方法を学んでください。