List Your Numbers
This page shows you how to list the numbers that you own programmatically.
You can also view your numbers online, using the developer dashboard or from the command line, using the Vonage CLI.
Replace the following variables in the sample code with your own values:
| キー | 説明 |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
NUMBER_SEARCH_CRITERIA | The filter criteria. For example, numbers containing |
NUMBER_SEARCH_PATTERN | Where the
|
Run your code
Save this file to your machine and run it:
Prerequisites
Create a file named list-numbers.js and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
Create a class named ListOwnedNumbers 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 ListOwnedNumbers class:
val numbers = client.numbers.listOwned {
pattern(NUMBER_SEARCH_PATTERN, NUMBER_SEARCH_CRITERIA)
}
for (number in numbers) {
println("""
Tel: ${number.msisdn}
Country: ${number.country}
Type: ${number.type}
""".trimIndent()
)
}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.numbers with the package containing ListOwnedNumbers:
Prerequisites
Add the following to build.gradle:
Create a class named ListNumbers 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 ListNumbers class:
List<OwnedNumber> response = client.getNumbersClient().listNumbers(
ListNumbersFilter.builder()
.pattern(NUMBER_SEARCH_PATTERN, NUMBER_SEARCH_CRITERIA)
.build()
);
for (OwnedNumber number : response) {
System.out.println("Tel: " + number.getMsisdn());
System.out.println("Type: " + number.getType());
System.out.println("Country: " + number.getCountry());
}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.numbers with the package containing ListNumbers:
Prerequisites
Create a file named ListOwnedNumbers.cs and add the following code:
using Vonage;
using Vonage.Numbers;
using Vonage.Request;Add the following to ListOwnedNumbers.cs:
var credentials = Credentials.FromApiKeyAndSecret(vonageApiKey, vonageApiSecret);Write the code
Add the following to ListOwnedNumbers.cs:
var request = new NumberSearchRequest()
{
SearchPattern = numberSearchPattern,
Pattern = numberSearchCriteria
};
Prerequisites
Create a file named list-owned.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
Run your code
Save this file to your machine and run it:
Prerequisites
Create a file named list.rb and add the following code:
Run your code
Save this file to your machine and run it: