空き番号検索

このページでは、購入可能な Numbers をプログラムで検索する方法を紹介します。

また、オンラインで利用可能な Numbers を検索することもできます。 開発者ダッシュボード またはコマンドラインから Vonage CLI.

サンプルコードの以下の変数を、独自の値に置き換えてください:

キー説明
VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

COUNTRY_CODE

The two digit country code for the number. For example: GB for the United Kingdom

VONAGE_NUMBER_TYPE

The type of number: landline, mobile-lvn or landline-toll-free

VONAGE_NUMBER_FEATURES

The capabilities of the number: SMS, VOICE or SMS,VOICE for both

NUMBER_SEARCH_CRITERIA

The filter criteria. For example, numbers containing 234.

NUMBER_SEARCH_PATTERN

Where the NUMBER_SEARCH_CRITERIA should appear in the number:

  • 0 - At the beginning of the number
  • 1- Anywhere in the number
  • 2 - At the end of the number

Write the code

Add the following to search-numbers.sh:

curl "https://rest.nexmo.com/number/search?api_key=$VONAGE_API_KEY&api_secret=$VONAGE_API_SECRET&country=$COUNTRY_CODE&type=$VONAGE_NUMBER_TYPE&features=$VONAGE_NUMBER_FEATURES&pattern=$NUMBER_SEARCH_CRITERIA&search_pattern=$NUMBER_SEARCH_PATTERN"

View full source

Run your code

Save this file to your machine and run it:

sh search-numbers.sh

参照