You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/telephony/includes/number-lookup-java.md
+63-29Lines changed: 63 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
-
Get started with the Phone Numbers client library for Java to look up operator information for phone numbers, which can be used to determine whether and how to communicate with that phone number. Follow these steps to install the package and look up operator information about a phone number.
1
+
Get started with the Phone Numbers client library for Java to look up operator information for phone numbers, which can be used to determine whether and how to communicate with that phone number. Follow these steps to install the package and look up operator information about a phone number.
2
2
3
3
> [!NOTE]
4
-
> Find the code for this quickstart on [GitHub](https://github.com/Azure/communication-preview/tree/master/samples/NumberLookup).
4
+
> Find the code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-java-quickstarts/tree/main/LookupNumber).
The 'generate' task creates a directory with the same name as the `artifactId`. Under this directory, the src/main/java directory contains the project source code, the `src/test/java directory` contains the test source, and the `pom.xml` file is the project's Project Object Model, or POM.
30
30
31
31
### Connect to dev package feed
32
-
The public preview version of the SDK is published to a dev package feed. To connect to the dev feed, open the **pom.xml** file in your text editor and add the dev repo to **both** your pom.xml's `<repositories>` and `<distributionManagement>` sections
32
+
The public preview version of the SDK is published to a dev package feed. To connect to the dev feed, open the **pom.xml** file in your text editor and add the dev repo to **both** your pom.xml's `<repositories>` and `<distributionManagement>` sections that you can add if they don't already exist.
33
33
34
34
```xml
35
35
<repository>
@@ -44,7 +44,7 @@ The public preview version of the SDK is published to a dev package feed. To con
44
44
</repository>
45
45
```
46
46
47
-
Add or edit the `settings.xml` file in `${user.home}/.m2`
47
+
You may need to add or edit the `settings.xml` file in `${user.home}/.m2`
48
48
49
49
```xml
50
50
<server>
@@ -54,7 +54,7 @@ Add or edit the `settings.xml` file in `${user.home}/.m2`
54
54
</server>
55
55
```
56
56
57
-
Finally, generate a [Personal Access Token](https://dev.azure.com/azure-sdk/_details/security/tokens) with _Packaging_ read & write scopes and paste it into the `<password>` tag.
57
+
You can generate a [Personal Access Token](https://dev.azure.com/azure-sdk/_details/security/tokens) with _Packaging_ read & write scopes and paste it into the `<password>` tag.
58
58
59
59
More detailed information and other options for connecting to the dev feed can be found [here](https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-java/connect).
60
60
@@ -72,7 +72,7 @@ Add the following dependency elements to the group of dependencies in the **pom.
The `PhoneNumberClientBuilder` is enabled to use Microsoft Entra authentication. Using the `DefaultAzureCredentialBuilder` is the easiest way to get started with Microsoft Entra ID. You can acquire your resource name from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com).
The client can be authenticated using a connection string acquired from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com). Using a `COMMUNICATION_SERVICES_CONNECTION_STRING` environment variable is recommended to avoid putting your connection string in plain text within your code. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string).
Alternatively, the client can be authenticated using a connection string, also acquired from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com). It's recommended to use a `COMMUNICATION_SERVICES_CONNECTION_STRING` environment variable to avoid putting your connection string in plain text within your code. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string).
Alternatively, you can authenticate using Microsoft Entra authentication. Using the `DefaultAzureCredentialBuilder` is the easiest way to get started with Microsoft Entra ID. You can acquire your resource name from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com).
Replace `<target-phone-number>` with the phone number you're looking up, usually a number you'd like to send a message to.
164
175
165
176
> [!WARNING]
166
177
> Provide phone numbers in E.164 international standard format, for example, +14255550123.
167
178
179
+
### Look up operator information for a number
180
+
181
+
To search for a phone number's operator information, call `searchOperatorInformationWithResponse` from the `PhoneNumbersClient`, passing `true` for the `IncludeAdditionalOperatorDetails` option.
System.out.println(operatorInfo.getPhoneNumber() +" is a "+ numberType +" number, operated by "+ operatorName);
214
+
System.out.println(operatorInfo.getPhoneNumber() +" is a "+ numberType +" number, operated in "
215
+
+ operatorInfo.getIsoCountryCode() +" by "+ operatorName);
182
216
```
183
217
184
-
You may also use the operator information to determine whether to send an SMS. For more information on sending an SMS, see the [SMS Quickstart](../../sms/send.md).
218
+
You may also use the operator information to determine whether to send an SMS. For more information on sending an SMS, see the [SMS Quickstart](../../sms/send.md).
185
219
186
220
## Run the code
187
221
@@ -198,12 +232,12 @@ Then, build the package.
198
232
mvn package
199
233
```
200
234
201
-
Run the following `mvn` command to execute the app.
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/telephony/includes/number-lookup-js.md
+35-14Lines changed: 35 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
Get started with the Phone Numbers client library for JavaScript to look up operator information for phone numbers, which can be used to determine whether and how to communicate with that phone number. Follow these steps to install the package and look up operator information about a phone number.
1
+
Get started with the Phone Numbers client library for JavaScript to look up operator information for phone numbers, which can be used to determine whether and how to communicate with that phone number. Follow these steps to install the package and look up operator information about a phone number.
2
2
3
3
> [!NOTE]
4
-
> Find the code for this quickstart on [GitHub](https://github.com/Azure/communication-preview/tree/master/samples/NumberLookup).
4
+
> Find the code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/lookup-phone-number).
5
5
6
6
## Prerequisites
7
7
8
8
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
9
-
-[Node.js](https://nodejs.org/) Active LTS and Maintenance LTS versions (8.11.1 and 10.14.1 recommended).
9
+
-[Node.js](https://nodejs.org/) Active LTS _(long-term support)_and Maintenance LTS versions (8.11.1 and 10.14.1 recommended).
10
10
- An active Communication Services resource and connection string. [Create a Communication Services resource](../../create-communication-resource.md).
11
11
12
12
### Prerequisite check
@@ -35,7 +35,7 @@ Create a file called **number-lookup-quickstart.js** in the root of the director
35
35
36
36
```javascript
37
37
asyncfunctionmain() {
38
-
// quickstart code will here
38
+
// quickstart code will go here
39
39
}
40
40
41
41
main();
@@ -46,7 +46,7 @@ main();
46
46
Use the `npm install` command to install the Azure Communication Services Phone Numbers client library for JavaScript.
The `--save` option adds the library as a dependency in your **package.json** file.
@@ -55,9 +55,9 @@ The `--save` option adds the library as a dependency in your **package.json** fi
55
55
56
56
### Authenticate the client
57
57
58
-
Import the **PhoneNumbersClient** from the client library and instantiate it with your connection string, which can be acquired from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com). It's recommended to use a `COMMUNICATION_SERVICES_CONNECTION_STRING` environment variable to avoid putting your connection string in plain text within your code. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string).
58
+
Import the **PhoneNumbersClient** from the client library and instantiate it with your connection string, which can be acquired from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com). Using a `COMMUNICATION_SERVICES_CONNECTION_STRING` environment variable is recommended to avoid putting your connection string in plain text within your code. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string).
59
59
60
-
Add the following code to the top of **phone-numbers-quickstart.js**:
60
+
Add the following code to the top of **number-lookup-quickstart.js**:
Replace `<target-phone-number>` with the phone number you're looking up, usually a number you'd like to send a message to.
81
81
82
82
> [!WARNING]
83
83
> Provide phone numbers in E.164 international standard format, for example, +14255550123.
84
84
85
+
### Look up operator information for a number
86
+
87
+
To search for a phone number's operator information, call `searchOperatorInformation` from the `PhoneNumbersClient`, passing `true` for the `includeAdditionalOperatorDetails` option.
88
+
89
+
```javascript
90
+
let searchResults =awaitphoneNumbersClient.searchOperatorInformation([ "<target-phone-number>" ], { "includeAdditionalOperatorDetails":true });
91
+
```
92
+
93
+
> [!WARNING]
94
+
> Using this functionality will incur a charge to your account.
95
+
85
96
### Use operator information
86
97
87
-
You can now use the operator information. For this quickstart guide, we can print some of the details to the console.
98
+
You can now use the operator information. For this quickstart guide, we can print some of the details to the console.
99
+
100
+
First, we can print details about the number format.
101
+
102
+
```javascript
103
+
let formatInfo =formattingResults.values[0];
104
+
console.log(formatInfo.phoneNumber+" is formatted "+formatInfo.internationalFormat+" internationally, and "+formatInfo.nationalFormat+" nationally");
105
+
```
106
+
107
+
Next, we can print details about the phone number and operator.
88
108
89
109
```javascript
90
-
let operatorInfo =results.values[0];
91
-
console.log(operatorInfo.phoneNumber+" is a "+ (operatorInfo.numberType?operatorInfo.numberType:"unknown") +" number, operated by "+ (operatorInfo.operatorDetails.name?operatorInfo.operatorDetails.name:"an unknown operator"));
110
+
let operatorInfo =searchResults.values[0];
111
+
console.log(operatorInfo.phoneNumber+" is a "+ (operatorInfo.numberType?operatorInfo.numberType:"unknown") +" number, operated in "
112
+
+operatorInfo.isoCountryCode+" by "+ (operatorInfo.operatorDetails.name?operatorInfo.operatorDetails.name:"an unknown operator"));
92
113
```
93
114
94
-
You may also use the operator information to determine whether to send an SMS. For more information on sending an SMS, see the [SMS Quickstart](../../sms/send.md).
115
+
You may also use the operator information to determine whether to send an SMS. For more information on sending an SMS, see the [SMS Quickstart](../../sms/send.md).
You can download the sample app from [GitHub](https://github.com/Azure/communication-preview/tree/master/samples/NumberLookup).
127
+
You can download the sample app from [GitHub](https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/lookup-phone-number)).
0 commit comments