다음을 통해 공유


빠른 시작: Azure Communication Services를 사용하여 전화 번호에 대한 사업자 정보 조회

Important

Azure Communication Services의 이 기능은 현재 미리 보기 상태입니다.

미리 보기 API 및 SDK는 서비스 수준 계약 없이 제공됩니다. 프로덕션 워크로드에는 사용하지 않는 것이 좋습니다. 일부 기능은 지원되지 않거나 기능이 제한될 수 있습니다.

자세한 내용은 Microsoft Azure 미리 보기에 대한 추가 사용 약관을 검토합니다.

JavaScript용 전화 번호 클라이언트 라이브러리를 시작하여 전화 번호에 대한 사업자 정보를 조회합니다.이 정보를 사용하여 해당 전화 번호와 통신할지 여부와 방법을 결정할 수 있습니다. 다음 단계에 따라 패키지를 설치하고 전화 번호에 대한 사업자 정보를 조회합니다.

참고 항목

GitHub에서 이 빠른 시작에 대한 코드를 찾습니다.

필수 조건

필수 구성 요소 확인

터미널 또는 명령 창에서 node --version 명령을 실행하여 Node.js가 설치되어 있는지 확인합니다.

설정

조회 쿼리 전송을 위한 환경을 설정하려면 다음 섹션의 단계를 수행합니다.

새 Node.js 애플리케이션 만들기

터미널 또는 명령 창에서 앱에 대한 새 디렉터리를 만들고 해당 디렉터리로 이동합니다.

mkdir number-lookup-quickstart && cd number-lookup-quickstart

npm init -y를 실행하여 기본 설정으로 package.json 파일을 만듭니다.

npm init -y

만들었던 디렉터리의 루트에 number-lookup-quickstart.js라는 파일을 만듭니다. 다음 조각을 추가합니다.

async function main() {
    // quickstart code will go here
}

main();

패키지 설치

npm install 명령을 사용하여 JavaScript용 Azure Communication Services 전화 번호 클라이언트 라이브러리를 설치합니다.

npm install @azure/communication-phone-numbers@1.3.0-beta.4 --save

--save 옵션은 라이브러리를 package.json 파일의 종속성으로 추가합니다.

코드 예제

클라이언트 인증

클라이언트 라이브러리에서 PhoneNumbersClient를 가져와서 Azure Portal의 Azure Communication Services 리소스에서 가져올 수 있는 연결 문자열을 사용해 인스턴스화합니다. 코드 내에서 연결 문자열을 일반 텍스트로 배치하지 않도록 COMMUNICATION_SERVICES_CONNECTION_STRING 환경 변수를 사용하는 것이 좋습니다. 리소스의 연결 문자열을 관리하는 방법을 알아봅니다.

number-lookup-quickstart.js의 맨 위에 다음 코드를 추가합니다.

const { PhoneNumbersClient } = require('@azure/communication-phone-numbers');

// This code retrieves your connection string from an environment variable
const connectionString = process.env['COMMUNICATION_SERVICES_CONNECTION_STRING'];

// Instantiate the phone numbers client
const phoneNumbersClient = new PhoneNumbersClient(connectionString);

전화 번호 서식 조회

전화 번호의 사업자 정보를 검색하려면 PhoneNumbersClient에서 searchOperatorInformation를 호출합니다.

let formattingResults = await phoneNumbersClient.searchOperatorInformation([ "<target-phone-number>" ]);

<target-phone-number>를 찾고 있는 전화 번호(일반적으로 메시지를 보내려는 번호)로 바꿉니다.

Warning

E.164 국가별 표준 형식(예: +14255550123)으로 전화번호를 입력합니다.

번호에 대한 사업자 정보 조회

전화 번호의 사업자 정보를 검색하려면 includeAdditionalOperatorDetails 옵션에 대해 true를 전달하여 PhoneNumbersClient에서 searchOperatorInformation을 호출합니다.

let searchResults = await phoneNumbersClient.searchOperatorInformation([ "<target-phone-number>" ], { "includeAdditionalOperatorDetails": true });

Warning

이 기능을 사용하면 계정에 요금이 부과됩니다.

사업자 정보 사용

이제 사업자 정보를 사용할 수 있습니다. 이 빠른 시작 가이드의 경우 일부 세부 정보를 콘솔에 인쇄할 수 있습니다.

먼저 숫자 형식에 대한 세부 정보를 인쇄할 수 있습니다.

let formatInfo = formattingResults.values[0];
console.log(formatInfo.phoneNumber + " is formatted " + formatInfo.internationalFormat + " internationally, and " + formatInfo.nationalFormat + " nationally");

다음으로 전화 번호 및 사업자에 대한 세부 정보를 인쇄할 수 있습니다.

let operatorInfo = searchResults.values[0];
console.log(operatorInfo.phoneNumber + " is a " + (operatorInfo.numberType ? operatorInfo.numberType : "unknown") + " number, operated in "
    + operatorInfo.isoCountryCode + " by " + (operatorInfo.operatorDetails.name ? operatorInfo.operatorDetails.name : "an unknown operator"));

사업자 정보를 사용하여 SMS를 보낼지 여부를 결정할 수도 있습니다. SMS를 보내는 방법에 대한 자세한 내용은 SMS 빠른 시작을 참조하세요.

코드 실행

node 명령을 사용하여 터미널 또는 명령 창에서 애플리케이션을 실행합니다.

node number-lookup-quickstart.js

샘플 코드

샘플 앱은 GitHub에서 다운로드할 수 있습니다.

C#용 전화 번호 클라이언트 라이브러리를 시작하여 전화 번호에 대한 사업자 정보를 조회합니다.이 정보를 사용하여 해당 전화 번호와 통신할지 여부와 방법을 결정할 수 있습니다. 다음 단계에 따라 패키지를 설치하고 전화 번호에 대한 사업자 정보를 조회합니다.

참고 항목

GitHub에서 이 빠른 시작에 대한 코드를 찾습니다.

필수 조건

필수 구성 요소 확인

터미널 또는 명령 창에서 dotnet 명령을 실행하여 .NET SDK가 설치되어 있는지 확인합니다.

설정

조회 쿼리 전송을 위한 환경을 설정하려면 다음 섹션의 단계를 수행합니다.

새 C# 애플리케이션 만들기

터미널 또는 명령 창에서 dotnet new 명령을 실행하여 이름 NumberLookupQuickstart로 새 콘솔 앱을 만듭니다. 이 명령은 program.cs라는 단일 원본 파일을 사용하여 간단한 "Hello World" C# 프로젝트를 만듭니다.

dotnet new console -o NumberLookupQuickstart

디렉터리를 새로 만든 앱 폴더로 변경하고 dotnet build 명령을 사용하여 애플리케이션을 컴파일합니다.

cd NumberLookupQuickstart
dotnet build

개발 패키지 피드에 연결

SDK의 공개 미리 보기 버전은 개발 패키지 피드에 게시됩니다. NuGet CLI를 사용하여 개발 피드를 추가하여 NuGet.Config 파일에 추가할 수 있습니다.

nuget sources add -Name "Azure SDK for .NET Dev Feed" -Source "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json"

개발자 피드에 연결하기 위한 자세한 정보 및 기타 옵션은 기여 가이드에서 찾을 수 있습니다.

패키지 설치

애플리케이션 디렉터리에 있는 동안 다음 명령을 사용하여 .NET 패키지용 Azure Communication Services PhoneNumbers 클라이언트 라이브러리를 설치합니다.

dotnet add package Azure.Communication.PhoneNumbers --version 1.3.0-beta.5

Program.cs의 맨 위에 using 지시어를 추가하여 Azure.Communication 네임스페이스를 포함합니다.

using System;
using System.Threading.Tasks;
using Azure.Communication.PhoneNumbers;

Main 함수 시그니처를 비동기화하도록 업데이트합니다.

internal class Program
{
    static async Task Main(string[] args)
    {
        ...
    }
}

코드 예제

클라이언트 인증

전화 번호 클라이언트는 Azure Portal의 Azure Communication Services 리소스에서 가져온 연결 문자열을 사용하여 인증할 수 있습니다. 코드 내에서 연결 문자열을 일반 텍스트로 배치하지 않도록 COMMUNICATION_SERVICES_CONNECTION_STRING 환경 변수를 사용하는 것이 좋습니다. 리소스의 연결 문자열을 관리하는 방법을 알아봅니다.

// This code retrieves your connection string from an environment variable.
string? connectionString = Environment.GetEnvironmentVariable("COMMUNICATION_SERVICES_CONNECTION_STRING");

PhoneNumbersClient client = new PhoneNumbersClient(connectionString, new PhoneNumbersClientOptions(PhoneNumbersClientOptions.ServiceVersion.V2024_03_01_Preview));

전화 번호 클라이언트는 Microsoft Entra 인증을 사용하여 인증할 수도 있습니다. 이 옵션을 사용하는 경우 인증을 위해 AZURE_CLIENT_SECRET, AZURE_CLIENT_IDAZURE_TENANT_ID 환경 변수를 설정해야 합니다.

// Get an endpoint to our Azure Communication Services resource.
Uri endpoint = new Uri("<endpoint_url>");
TokenCredential tokenCredential = new DefaultAzureCredential();
client = new PhoneNumbersClient(endpoint, tokenCredential);

전화 번호 서식 조회

번호에 대한 국내 및 국제 서식을 조회하려면 PhoneNumbersClient에서 SearchOperatorInformationAsync을 호출합니다.

OperatorInformationResult formattingResult = await client.SearchOperatorInformationAsync(new[] { "<target-phone-number>" });

<target-phone-number>를 찾고 있는 전화 번호(일반적으로 메시지를 보내려는 번호)로 바꿉니다.

Warning

E.164 국가별 표준 형식(예: +14255550123)으로 전화번호를 입력합니다.

번호에 대한 사업자 정보 조회

전화 번호의 사업자 정보를 검색하려면 IncludeAdditionalOperatorDetails 옵션에 대해 true를 전달하여 PhoneNumbersClient에서 SearchOperatorInformationAsync을 호출합니다.

OperatorInformationResult searchResult = await client.SearchOperatorInformationAsync(new[] { "<target-phone-number>" }, new OperatorInformationOptions() { IncludeAdditionalOperatorDetails = true });

Warning

이 기능을 사용하면 계정에 요금이 부과됩니다.

사업자 정보 사용

이제 사업자 정보를 사용할 수 있습니다. 이 빠른 시작 가이드의 경우 일부 세부 정보를 콘솔에 인쇄할 수 있습니다.

먼저 숫자 형식에 대한 세부 정보를 인쇄할 수 있습니다.

OperatorInformation formattingInfo = formattingResult.Values[0];
Console.WriteLine($"{formattingInfo.PhoneNumber} is formatted {formattingInfo.InternationalFormat} internationally, and {formattingInfo.NationalFormat} nationally");

다음으로 전화 번호 및 사업자에 대한 세부 정보를 인쇄할 수 있습니다.

OperatorInformation operatorInformation = searchResult.Values[0];
Console.WriteLine($"{operatorInformation.PhoneNumber} is a {operatorInformation.NumberType ?? "unknown"} number, operated in {operatorInformation.IsoCountryCode} by {operatorInformation.OperatorDetails.Name ?? "an unknown operator"}");

사업자 정보를 사용하여 SMS를 보낼지 여부를 결정할 수도 있습니다. SMS를 보내는 방법에 대한 자세한 내용은 SMS 빠른 시작을 참조하세요.

코드 실행

dotnet run 명령을 사용하여 터미널 또는 명령 창에서 애플리케이션을 실행합니다.

dotnet run --interactive

샘플 코드

샘플 앱은 GitHub에서 다운로드할 수 있습니다.

Java용 전화 번호 클라이언트 라이브러리를 시작하여 전화 번호에 대한 사업자 정보를 조회합니다.이 정보를 사용하여 해당 전화 번호와 통신할지 여부와 방법을 결정할 수 있습니다. 다음 단계에 따라 패키지를 설치하고 전화 번호에 대한 사업자 정보를 조회합니다.

참고 항목

GitHub에서 이 빠른 시작에 대한 코드를 찾습니다.

필수 조건

필수 구성 요소 확인

터미널 또는 명령 창에서 mvn -v 명령을 실행하여 Maven이 설치되어 있는지 확인합니다.

설정

조회 쿼리 전송을 위한 환경을 설정하려면 다음 섹션의 단계를 수행합니다.

새 Java 애플리케이션 만들기

터미널 또는 명령 창에서 Java 애플리케이션을 만들려는 디렉터리로 이동합니다. 다음 명령을 실행하여 maven-archetype-quickstart 템플릿에서 Java 프로젝트를 생성합니다.

mvn archetype:generate -DgroupId=com.communication.lookup.quickstart -DartifactId=communication-lookup-quickstart -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

‘generate’ 작업은 artifactId와 이름이 같은 디렉터리를 만듭니다. 이 디렉터리 아래에서 src/main/java 디렉터리는 프로젝트 소스 코드를 포함하고, src/test/java directory는 테스트 원본을 포함하고, pom.xml 파일은 프로젝트의 프로젝트 개체 모델 또는 POM입니다.

개발 패키지 피드에 연결

SDK의 공개 미리 보기 버전은 개발 패키지 피드에 게시됩니다. 개발 피드에 연결하려면 텍스트 편집기에서 pom.xml 파일을 열고 pom.xml의 <repositories><distributionManagement> 섹션(없는 경우 직접 추가할 수 있음) 모두에 개발 리포지토리를 추가합니다.

<repository>
  <id>azure-sdk-for-java</id>
  <url>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-java/maven/v1</url>
  <releases>
    <enabled>true</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

${user.home}/.m2에서 settings.xml 파일을 추가하거나 편집해야 할 수 있습니다.

<server>
  <id>azure-sdk-for-java</id>
  <username>azure-sdk</username>
  <password>[PERSONAL_ACCESS_TOKEN]</password>
</server>

패키징 읽기 및 쓰기 범위를 사용하여 개인용 액세스 토큰을 생성하고 <password> 태그에 붙여넣을 수 있습니다.

개발자 피드에 연결하기 위한 자세한 정보 및 기타 옵션은 여기에서 찾을 수 있습니다.

패키지 설치

pom.xml 파일에서 종속성 그룹에 다음 종속성 요소를 추가합니다.

<dependencies>
  <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-communication-common</artifactId>
    <version>1.0.0</version>
  </dependency>

  <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-communication-phonenumbers</artifactId>
    <version>1.2.0-beta.3</version>
  </dependency>

  <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-identity</artifactId>
    <version>1.2.3</version>
  </dependency>

  <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-core</artifactId>
    <version>1.41.0</version>
  </dependency>
</dependencies>

properties 섹션을 확인하여 프로젝트가 Maven 버전 1.8 이상을 대상으로 하는지 확인합니다.

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>

코드 예제

앱 프레임워크 설정

프로젝트 디렉터리에서 다음을 수행합니다.

  1. /src/main/java/com/communication/lookup/quickstart 디렉터리로 이동합니다.
  2. 편집기에서 App.java 파일을 엽니다.
  3. System.out.println("Hello world!"); 문 바꾸기
  4. import 지시문 추가

시작하려면 다음 코드를 사용합니다.

package com.communication.lookup.quickstart;

import com.azure.communication.phonenumbers.*;
import com.azure.communication.phonenumbers.models.*;
import com.azure.core.http.rest.*;
import com.azure.core.util.Context;
import com.azure.identity.*;
import java.io.*;
import java.util.ArrayList;

public class App
{
    public static void main( String[] args ) throws IOException
    {
        System.out.println("Azure Communication Services - Number Lookup Quickstart");
        // Quickstart code goes here
    }
}

클라이언트 인증

Azure Portal의 Azure Communication Services 리소스에서 가져온 연결 문자열을 사용하여 클라이언트를 인증할 수 있습니다. 코드 내에서 연결 문자열을 일반 텍스트로 배치하지 않도록 COMMUNICATION_SERVICES_CONNECTION_STRING 환경 변수를 사용하는 것이 좋습니다. 리소스의 연결 문자열을 관리하는 방법을 알아봅니다.

// This code retrieves your connection string from an environment variable
String connectionString = System.getenv("COMMUNICATION_SERVICES_CONNECTION_STRING");

PhoneNumbersClient phoneNumberClient = new PhoneNumbersClientBuilder()
    .connectionString(connectionString)
    .buildClient();

또는 Microsoft Entra 인증을 사용하여 인증할 수도 있습니다. Microsoft Entra ID를 시작하는 가장 쉬운 방법은 DefaultAzureCredentialBuilder를 사용하는 것입니다. Azure Portal의 Azure Communication Services 리소스에서 리소스 이름을 가져올 수 있습니다.

// You can find your resource name from your resource in the Azure portal
String endpoint = "https://<RESOURCE_NAME>.communication.azure.com";

PhoneNumbersClient phoneNumberClient = new PhoneNumbersClientBuilder()
    .endpoint(endpoint)
    .credential(new DefaultAzureCredentialBuilder().build())
    .buildClient();

전화 번호 서식 조회

번호에 대한 국내 및 국제 서식을 조회하려면 PhoneNumbersClient에서 searchOperatorInformation을 호출합니다.

ArrayList<String> phoneNumbers = new ArrayList<String>();
phoneNumbers.add("<target-phone-number>");

// Use the free number lookup functionality to get number formatting information
OperatorInformationResult formattingResult = phoneNumberClient.searchOperatorInformation(phoneNumbers);
OperatorInformation formattingInfo = formattingResult.getValues().get(0);

<target-phone-number>를 찾고 있는 전화 번호(일반적으로 메시지를 보내려는 번호)로 바꿉니다.

Warning

E.164 국가별 표준 형식(예: +14255550123)으로 전화번호를 입력합니다.

번호에 대한 사업자 정보 조회

전화 번호의 사업자 정보를 검색하려면 IncludeAdditionalOperatorDetails 옵션에 대해 true를 전달하여 PhoneNumbersClient에서 searchOperatorInformationWithResponse을 호출합니다.

OperatorInformationOptions options = new OperatorInformationOptions();
options.setIncludeAdditionalOperatorDetails(true);
Response<OperatorInformationResult> result = phoneNumberClient.searchOperatorInformationWithResponse(phoneNumbers, options, Context.NONE);
OperatorInformation operatorInfo = result.getValue().getValues().get(0);

Warning

이 기능을 사용하면 계정에 요금이 부과됩니다.

사업자 정보 사용

이제 사업자 정보를 사용할 수 있습니다. 이 빠른 시작 가이드의 경우 일부 세부 정보를 콘솔에 인쇄할 수 있습니다.

먼저 숫자 형식에 대한 세부 정보를 인쇄할 수 있습니다.

System.out.println(formattingInfo.getPhoneNumber() + " is formatted "
    + formattingInfo.getInternationalFormat() + " internationally, and "
    + formattingInfo.getNationalFormat() + " nationally");

다음으로 전화 번호 및 사업자에 대한 세부 정보를 인쇄할 수 있습니다.

String numberType = operatorInfo.getNumberType() == null ? "unknown" : operatorInfo.getNumberType().toString();
String operatorName = "an unknown operator";
if (operatorInfo.getOperatorDetails()!= null && operatorInfo.getOperatorDetails().getName() != null)
{
    operatorName = operatorInfo.getOperatorDetails().getName();
}
System.out.println(operatorInfo.getPhoneNumber() + " is a " + numberType + " number, operated in "
    + operatorInfo.getIsoCountryCode() + " by " + operatorName);

사업자 정보를 사용하여 SMS를 보낼지 여부를 결정할 수도 있습니다. SMS를 보내는 방법에 대한 자세한 내용은 SMS 빠른 시작을 참조하세요.

코드 실행

다음 명령을 사용하여 터미널 또는 명령 창에서 애플리케이션을 실행합니다. pom.xml 파일이 포함된 디렉터리로 이동하여 프로젝트를 컴파일합니다.

mvn compile

그런 다음, 패키지를 빌드합니다.

mvn package

앱을 실행하려면 mvn 명령을 실행합니다.

mvn exec:java -D"exec.mainClass"="com.communication.lookup.quickstart.App" -D"exec.cleanupDaemonThreads"="false"

샘플 코드

샘플 앱은 GitHub에서 다운로드할 수 있습니다.

Pathon용 전화 번호 클라이언트 라이브러리를 시작하여 전화 번호에 대한 사업자 정보를 조회합니다. 이 정보를 사용하여 해당 전화 번호와 통신할지 여부와 방법을 결정할 수 있습니다. 다음 단계에 따라 패키지를 설치하고 전화 번호에 대한 사업자 정보를 조회합니다.

참고 항목

GitHub에서 이 빠른 시작에 대한 코드를 찾습니다.

필수 조건

필수 구성 요소 확인

터미널 또는 명령 창에서 python --version 명령을 실행하여 Python이 설치되어 있는지 확인합니다.

설정

조회 쿼리 전송을 위한 환경을 설정하려면 다음 섹션의 단계를 수행합니다.

새 Python 애플리케이션 만들기

터미널 또는 명령 창에서 앱에 대한 새 디렉터리를 만들고 해당 디렉터리로 이동합니다.

mkdir number-lookup-quickstart && cd number-lookup-quickstart

텍스트 편집기를 사용하여 number_lookup_sample.py라고 하는 파일을 프로젝트 루트 디렉터리에 만들고 다음 코드를 추가합니다. 다음 섹션에서 나머지 빠른 시작 코드를 추가합니다.

import os
from azure.communication.phonenumbers import PhoneNumbersClient

try:
   print('Azure Communication Services - Number Lookup Quickstart')
   # Quickstart code goes here
except Exception as ex:
   print('Exception:')
   print(ex)

패키지 설치

애플리케이션 디렉터리에 있는 동안 pip install 명령을 사용하여 Python 패키지용 Azure Communication Services PhoneNumbers 클라이언트 라이브러리를 설치합니다.

pip install azure-communication-phonenumbers==1.2.0b2

코드 예제

클라이언트 인증

Azure Portal의 Azure Communication Services 리소스에서 가져온 연결 문자열을 사용하여 클라이언트를 인증할 수 있습니다. 코드 내에서 연결 문자열을 일반 텍스트로 배치하지 않도록 COMMUNICATION_SERVICES_CONNECTION_STRING 환경 변수를 사용하는 것이 좋습니다. 리소스의 연결 문자열을 관리하는 방법을 알아봅니다.

# This code retrieves your connection string from an environment variable
connection_string = os.getenv('COMMUNICATION_SERVICES_CONNECTION_STRING')
try:
    phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_string)
except Exception as ex:
    print('Exception:')
    print(ex)

또는 Microsoft Entra 인증을 사용하여 클라이언트를 인증할 수도 있습니다. DefaultAzureCredential 개체를 사용하면 가장 손쉽게 Microsoft Entra ID를 시작할 수 있으며 pip install 명령을 사용하여 설치할 수 있습니다.

pip install azure-identity

DefaultAzureCredential 개체를 만들려면 등록된 Microsoft Entra 애플리케이션에서 AZURE_CLIENT_ID, AZURE_CLIENT_SECRETAZURE_TENANT_ID가 해당 값을 사용하여 환경 변수로 이미 등록되어 있어야 합니다.

이러한 환경 변수를 가져오는 방법을 자세히 알아보려면 CLI에서 서비스 주체를 설정하는 방법을 살펴보면 됩니다.

azure-identity 라이브러리가 설치되었으면 클라이언트를 계속 인증할 수 있습니다.

from azure.identity import DefaultAzureCredential

# You can find your endpoint from your resource in the Azure portal
endpoint = 'https://<RESOURCE_NAME>.communication.azure.com'
try:
    credential = DefaultAzureCredential()
    phone_numbers_client = PhoneNumbersClient(endpoint, credential)
except Exception as ex:
    print('Exception:')
    print(ex)

전화 번호 서식 조회

번호에 대한 국내 및 국제 서식을 조회하려면 PhoneNumbersClient에서 search_operator_information을 호출합니다.

formatting_results = phone_numbers_client.search_operator_information("<target-phone-number>")

<target-phone-number>를 찾고 있는 전화 번호(일반적으로 메시지를 보내려는 번호)로 바꿉니다.

Warning

E.164 국가별 표준 형식(예: +14255550123)으로 전화번호를 입력합니다.

번호에 대한 사업자 정보 조회

전화 번호의 사업자 정보를 검색하려면 include_additional_operator_details 옵션에 대해 True를 전달하여 PhoneNumbersClient에서 search_operator_information을 호출합니다.

options = { "include_additional_operator_details": True }
operator_results = phone_numbers_client.search_operator_information("<target-phone-number>", options)

Warning

이 기능을 사용하면 계정에 요금이 부과됩니다.

사업자 정보 사용

이제 사업자 정보를 사용할 수 있습니다. 이 빠른 시작 가이드의 경우 일부 세부 정보를 콘솔에 인쇄할 수 있습니다.

먼저 숫자 형식에 대한 세부 정보를 인쇄할 수 있습니다.

formatting_info = formatting_results.values[0]
print(str.format("{0} is formatted {1} internationally, and {2} nationally", formatting_info.phone_number, formatting_info.international_format, formatting_info.national_format))

다음으로 전화 번호 및 사업자에 대한 세부 정보를 인쇄할 수 있습니다.

operator_information = operator_results.values[0]

number_type = operator_information.number_type if operator_information.number_type else "unknown"
if operator_information.operator_details is None or operator_information.operator_details.name is None:
    operator_name = "an unknown operator"
else:
    operator_name = operator_information.operator_details.name

print(str.format("{0} is a {1} number, operated in {2} by {3}", operator_information.phone_number, number_type, operator_information.iso_country_code, operator_name))

사업자 정보를 사용하여 SMS를 보낼지 여부를 결정할 수도 있습니다. SMS를 보내는 방법에 대한 자세한 내용은 SMS 빠른 시작을 참조하세요.

코드 실행

python 명령을 사용하여 터미널 또는 명령 창에서 애플리케이션을 실행합니다.

python number_lookup_sample.py

샘플 코드

샘플 앱은 GitHub에서 다운로드할 수 있습니다.

문제 해결

일반적인 질문 및 문제:

  • 환경 변수에 대한 변경 내용은 이미 실행 중인 프로그램에서 적용되지 않을 수 있습니다. 환경 변수가 예상대로 작동하지 않는 경우 코드를 실행하고 편집하는 데 사용하는 프로그램을 닫고 다시 열어 봅니다.
  • 이 엔드포인트에서 반환되는 데이터는 다양한 국제 법률 및 규정의 적용을 받으므로 결과의 정확도는 여러 요인에 따라 달라집니다. 이러한 요인에는 번호가 이동되었는지 여부, 국가 번호 및 발신자의 승인 상태가 포함됩니다. 이러한 요인에 따라 사업자 정보는 일부 전화 번호에 대해 제공되지 않거나 전화 번호의 현재 사업자가 아닌 원래 사업자를 반영할 수 있습니다.

다음 단계

이 빠른 시작에서는 다음을 수행하는 방법을 알아보았습니다.

  • 숫자 서식 조회
  • 전화 번호에 대한 사업자 정보 조회