REST API: 利用可能電話番号

The subresources of the AvailablePhoneNumbers resource let you search for local, toll-free and mobile phone numbers that are available for you to purchase. You can search for phone numbers that match a pattern, are in a certain country, are in certain area code (NPA) or exchange (NXX) or are in a specific geography.

購入したい番号が見つかったら、HTTP POST リクエストを IncomingPhoneNumbers リスト リソース に発行し、番号を PhoneNumber パラメーターとして渡します。

Twilio は、豊富な種類の番号をストックしています。 国別の購入可能な番号については、 料金ページ を参照してください。

AvailablePhoneNumber 国内番号 インスタンス リソース

リソースURI

AvailablePhoneNumber はURLをもちません。AvailablePhoneNumber インスタンスリソースに直接リクエストを送信することはできません。その代わりに、ローカルリストサブリソースへリクエストをう送信し、リストから電話番号を選択してください。

リソースのプロパティ

The following properties are available for all available phone number resources:

名前 概要
account_sid

The 34 character string that uniquely identifies your account. (🏢 not PII)

address_requirements

This indicates whether the phone number requires you or your customer to have an Address registered with Twilio. Possible values are none, any, local, or foreign. (🏢 not PII)

ベータ

Phone numbers new to the Twilio platform are marked as beta. Possible values are either true or false. (🏢 not PII)

capabilities

This is a set of boolean properties that indicate whether a phone number can receive calls or messages. Possible capabilities are Voice, SMS, MMS, and Fax with each having a value of either true or false. (🏢 not PII)

friendly_name

A nicely-formatted version of the phone number. (🏢 not PII)

iso_country

The ISO country code of this phone number. (🏢 not PII)

lata

The LATA of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

latitude

The latitude coordinate of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

locality

The locality/city of this phone number. (🏢 not PII)

longitude

The longitude coordinate of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

phone_number

The phone number, in E.164 (i.e. "+1") format. (🏢 not PII)

postal_code

The postal (zip) code of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

rate_center

The rate center of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

region

The two-letter state or province abbreviation of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

アドレス要件値

下記は address_required プロパティ として取りうる値です。

Status 概要
none このアドレスは電話番号に必要ではありません。
any このアカウントは住所を必要としています。しかし、世界中のどこでもご利用いただけます。
local このアカウントは電話番号の国の住所が必要です。
foreign あなたのアカウントは電話番号の国ではない住所が必要です。

AvailablePhoneNumber 無料電話番号インスタンス リソース

アメリカ、カナダ、イギリスの無料電話番号を購入できます。

リソースURI

An AvailablePhoneNumber Toll-Free instance resource has no URI. You cannot make requests directly to AvailablePhoneNumber instance resources. Instead, make a request to the toll-free list subresource and then choose a number from the list.

リソースのプロパティ

名前 概要
address_requirements

This indicates whether the phone number requires you or your customer to have an Address registered with Twilio. Possible values are none, any, local, or foreign. (🏢 not PII)

ベータ

Phone numbers new to the Twilio platform are marked as beta. Possible values are either true or false. (🏢 not PII)

capabilities

This is a set of boolean properties that indicate whether a phone number can receive calls or messages. Possible capabilities are Voice, SMS, MMS, and Fax with each having a value of either true or false. (🏢 not PII)

friendly_name

A nicely-formatted version of the phone number. (🏢 not PII)

iso_country

The ISO country code of this phone number. (🏢 not PII)

lata

The LATA of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

latitude

The latitude coordinate of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

locality

The locality/city of this phone number. (🏢 not PII)

longitude

The longitude coordinate of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

phone_number

The phone number, in E.164 (i.e. "+1") format. (🏢 not PII)

postal_code

The postal (zip) code of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

rate_center

The rate center of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

region

The two-letter state or province abbreviation of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)


AvailablePhoneNumber 携帯電話インスタンスリソース

リソースURI

AvailablePhoneNumber 携帯電話インスタンスリソースはURLを持ちませんAvailablePhoneNumber インスタンスリソースに直接リクエストを送ることはできません。その代わりに、携帯電話リストサブリソースにリクエストを送り、そのリストの中から番号を選択します。

リソースのプロパティ

名前 概要
address_requirements

This indicates whether the phone number requires you or your customer to have an Address registered with Twilio. Possible values are none, any, local, or foreign. (🏢 not PII)

ベータ

Phone numbers new to the Twilio platform are marked as beta. Possible values are either true or false. (🏢 not PII)

capabilities

This is a set of boolean properties that indicate whether a phone number can receive calls or messages. Possible capabilities are Voice, SMS, MMS, and Fax with each having a value of either true or false. (🏢 not PII)

friendly_name

A nicely-formatted version of the phone number. (🏢 not PII)

iso_country

The ISO country code of this phone number. (🏢 not PII)

lata

The LATA of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

latitude

The latitude coordinate of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

locality

The locality/city of this phone number. (🏢 not PII)

longitude

The longitude coordinate of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

phone_number

The phone number, in E.164 (i.e. "+1") format. (🏢 not PII)

postal_code

The postal (zip) code of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

rate_center

The rate center of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

region

The two-letter state or province abbreviation of this phone number. Available for phone numbers from the US and Canada. (🏢 not PII)

電話番号の検索と購入

Buy combining the AvailablePhoneNumbers lookup (examples below) with an IncomingPhoneNumbers purchase you can purchase any number based on a wide set of criteria. You can search for available numbers that match a specific pattern, are in a specific geographic area,or are near other numbers just to name a few. Once you've found a number you'd like to buy you simply POST the number to the IncomingPhoneNumbers resource.

AvailablePhoneNumbers 国内番号リスト サブリソース

リソースURI

/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{IsoCountryCode}/Local

{IsoCountryCode} は ISO 3166-1 alpha-2 フォーマットの国コードです。たとえば、カナダの ISO 国コードは CA です。 サポート対象国 の国名と Twilio がサポートする IsoCountryCode の完全なリストを参照してください。

HTTP GET

指定したフィルターに一致する国内番号の AvailablePhoneNumber リソース表現のリストを返します。各項目は、ユーザーのアカウントで現在プロビジョニング可能な電話番号を表現します。

基本的なリスト フィルター

次の基本的な GET クエリ パラメーターを使って、Twilio が返却する番号リストをフィルタリングできます。 パラメーターの大文字と小文字は区別されます。

名前 概要
AreaCode

Optional. Find phone numbers in the specified area code. (US and Canada only) (🏢 not PII)

ベータ

Optional. Include phone numbers new to the Twilio platform. Possible values are either true or false. Default is true. (🏢 not PII)

Contains

Optional. A pattern on which to match phone numbers. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit. See Example 2 and Example 3 below. NOTE: Patterns must be at least two characters long. (🏢 not PII)

Distance

Optional. Specifies the search radius for a Near- query in miles. If not specified this defaults to 25 miles. Maximum searchable distance is 500 miles. Limited to US and Canadian phone numbers. (🏢 not PII)

ExcludeAllAddressRequired

Optional. Indicates whether the response includes phone numbers which require any Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with an Address required. (🏢 not PII)

ExcludeForeignAddressRequired

Optional. Indicates whether the response includes phone numbers which require a foreign Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with a foreign Address required. (🏢 not PII)

ExcludeLocalAddressRequired

Optional. Indicates whether the response includes phone numbers which require a local Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with a local Address required. (🏢 not PII)

FaxEnabled

Optional. This indicates whether the phone numbers can receive faxes. Possible values are true or false. (🏢 not PII)

InLata

Optional. Limit results to a specific Local access and transport area (LATA). Given a phone number, search within the same LATA as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

InLocality

Optional. Limit results to a particular locality (i.e. City). Given a phone number, search within the same Locality as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

InPostalCode

Optional. Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

InRateCenter

Optional. Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well. Limited to US and Canadian phone numbers. (🏢 not PII)

InRegion

Optional. Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

MmsEnabled

Optional. This indicates whether the phone numbers can receive MMS messages. Possible values are true or false. (🏢 not PII)

NearLatLong

Optional. Given a latitude/longitude pair lat,long find geographically close numbers within Distance miles. Limited to US and Canadian phone numbers. (🏢 not PII)

NearNumber

Optional. Given a phone number, find a geographically close number within Distance miles. Distance defaults to 25 miles. Limited to US and Canadian phone numbers. (🏢 not PII)

SmsEnabled

Optional. This indicates whether the phone numbers can receive text messages. Possible values are true or false. (🏢 not PII)

VoiceEnabled

Optional. This indicates whether the phone numbers can receive calls. Possible values are true or false. (🏢 not PII)

購入可能な市内電話番号の検索

アメリカ国内の、エリア コード 510 で購入可能な番号を検索します。

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  areaCode: '510',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

// Find and then purchase a phone number
client
  .availablePhoneNumbers('US')
  .local.list({
    areaCode: '510',
  })
  .then(data => {
    const number = data[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.AreaCode = "510";
    
    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "AreaCode" => "510"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];

// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(area_code: '510')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US", areaCode: 510);

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("areaCode" => "510")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    area_code="510", country="US", type="local"
)
# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
client = Twilio::REST::Client.new(account_sid, auth_token)

# Retrieve available phone numbers in near specified latitude and longitude
# for the given account sid
numbers = client.api.available_phone_numbers('US')
                .local.list(area_code: '510')

number = numbers[0].phone_number

client.incoming_phone_numbers.create(phone_number: number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("AreaCode", "510");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(area_code="510")

# Purchase the phone number
number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setAreaCode(510).read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "AreaCode=510" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?AreaCode=510",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 564-7903",
      "phone_number": "+15105647903",
      "lata": "722",
      "rate_center": "OKLD TRNID",
      "latitude": "37.780000",
      "longitude": "-122.380000",
      "region": "CA",
      "postal_code": "94703",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
    {
      "friendly_name": "(510) 488-4379",
      "phone_number": "+15104884379",
      "lata": "722",
      "rate_center": "OKLD FRTVL",
      "latitude": "37.780000",
      "longitude": "-122.380000",
      "region": "CA",
      "postal_code": "94602",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
    ...
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?AreaCode=510">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 564-7903</FriendlyName>
      <PhoneNumber>+15105647903</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>OKLD TRNID</RateCenter>
      <Latitude>37.780000</Latitude>
      <Longitude>-122.380000</Longitude>
      <Region>CA</Region>
      <PostalCode>94703</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
    <AvailablePhoneNumber>
      <FriendlyName>(510) 488-4379</FriendlyName>
      <PhoneNumber>+15104884379</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>OKLD FRTVL</RateCenter>
      <Latitude>37.780000</Latitude>
      <Longitude>-122.380000</Longitude>
      <Region>CA</Region>
      <PostalCode>94602</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
    ...
  </AvailablePhoneNumbers>
</TwilioResponse>
購入可能な市内電話番号の検索

番号パターンによる電話番号の検索

アメリカ国内の、510555 で始まる購入可能な番号を検索します。

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  contains: '510555****',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    contains: '510555****',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.Contains = "510555****";
    
    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList('US', 'Local', array(
        "Contains" => "510555****"
    ));

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(contains: '510555****')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US",
                                                      contains: "510555****");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("contains" => "510555****")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="US", contains="510555****", type="local"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Retrieve available phone numbers that match the given pattern
@numbers = @client.api.available_phone_numbers('US').local
                  .list(contains: '510555****')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("Contains", "510555****");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(contains="510555****")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setContains("510555****").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "Contains=510555****" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?Contains=510555****",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 555-1214",
      "phone_number": "+15105551214",
      "lata": "722",
      "rate_center": "OKLD0349T",
      "latitude": "37.806940",
      "longitude": "-122.270360",
      "region": "CA",
      "postal_code": "94612",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?Contains=510555****">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 555-1214</FriendlyName>
      <PhoneNumber>+15105551214</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>OKLD0349T</RateCenter>
      <Latitude>37.806940</Latitude>
      <Longitude>-122.270360</Longitude>
      <Region>CA</Region>
      <PostalCode>94612</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
番号による電話番号の検索

パターンによる電話番号の検索

パターン「STORM」に一致する国内電話番号を検索します。

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  contains: 'STORM',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    contains: 'STORM',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.Contains = "STORM";

    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "Contains" => "STORM"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(contains: 'STORM')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US", contains: "STORM");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("contains" => "STORM")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="US", contains="STORM", type="local"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').local
                  .list(contains: 'STORM')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("Contains", "STORM");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(contains="STORM")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setContains("STORM").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "Contains=STORM" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?Contains=STORM",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 557-8676",
      "phone_number": "+15105578678",
      "lata": "722",
      "rate_center": "FRNK MAIN",
      "latitude": "37.557",
      "longitude": "-122.0073",
      "region": "CA",
      "postal_code": "94560",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?Contains=STORM">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 557-8676</FriendlyName>
      <PhoneNumber>+15105578676</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>FRNK MAIN</RateCenter>
      <Latitude>37.557</Latitude>
      <Longitude>-122.0073</Longitude>
      <Region>CA</Region>
      <PostalCode>94560</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
パターンによる電話番号の検索

州による購入可能な電話番号の検索

アーカンソー州の購入可能な電話番号を検索します。

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  inRegion: 'AR',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    inRegion: 'AR',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.InRegion = "AR";

    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "InRegion" => "AR"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(in_region: 'AR')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US", inRegion: "AR");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);
        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("inRegion" => "AR")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="US", type="local", in_region="AR"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').local
                  .list(in_region: 'AR')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("InRegion", "AR");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(in_region="AR")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setInRegion("AR").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "InRegion=AR" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?InRegion=AR",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 555-1212",
      "phone_number": "+15105551212",
      "lata": "528",
      "rate_center": "LITTLEROCK",
      "latitude": "34.7556",
      "longitude": "-92.318",
      "region": "AR",
      "postal_code": "72205",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?InRegion=AR">
    <AvailablePhoneNumber>
      <FriendlyName>(501) 555-1212</FriendlyName>
      <PhoneNumber>+15015551212</PhoneNumber>
      <Lata>528</Lata>
      <RateCenter>LITTLEROCK</RateCenter>
      <Latitude>34.7556</Latitude>
      <Longitude>-92.318</Longitude>
      <Region>AR</Region>
      <PostalCode>72205</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
州による購入可能な電話番号の検索

購入可能な市内電話番号の検索

SMSが有効なロンドンの電話番号(プレフィックスが+4420)を探してみましょう

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('GB').local.list({
  contains: ' 4420',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('GB')
  .local.list({
    contains: ' 4420',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.Contains = " 4420";
    
    var result = twilio.ListAvailableLocalPhoneNumbers("GB", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'GB', 'Local', array(
        "Contains" => " 4420"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('GB')
                .local.list(contains: ' 4420')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("GB",
                                                      contains: " 4420");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);
        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('GB')->local->read(
    array("contains" => "4420")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="GB", contains=" 4420", type="local"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').local
                  .list(contains: '4420')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("Contains", " 4420");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "GB", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("GB") \
                .local \
                .list(contains="4420")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("GB").setContains("4420").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/GB/Local.json \
    -d "Contains=%2B4420" \
    -d "SmsEnabled=true" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/GB\/Local.json?Contains=+4420&SmsEnabled=true",
  "available_phone_numbers": [
    {
      "friendly_name": "+442033224780",
      "phone_number": "+442033224780",
      "iso_country": "GB",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/GB/Local?Contains=+4420&SmsEnabled=true">
    <AvailablePhoneNumber>
      <FriendlyName>+442033224780</FriendlyName>
      <PhoneNumber>+442033224780</PhoneNumber>
      <IsoCountry>GB</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
プレフィックスによる購入可能な市内電話番号の検索

機能を指定した地域電話番号の検索

イギリスの音声、SMSが有効な電話番号を探してみましょう

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('GB').local.list({
  voiceEnabled: 'true',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('GB')
  .local.list({
    voiceEnabled: 'true',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.VoiceEnabled = true;
    
    var result = twilio.ListAvailableLocalPhoneNumbers("GB", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'GB', 'Local', array(
        "VoiceEnabled" => "true"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('GB')
                .local.list(voice_enabled: 'true')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("GB",
                                                      voiceEnabled: true);

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('GB')->local->read(
    array("voiceEnabled" => "true")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    voice_enabled="true", type="local", country="GB"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Get all available phone numbers in Great Britain which are voice enabled
@numbers = @client.api.available_phone_numbers('GB').local
                  .list(voice_enabled: 'true')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("VoiceEnabled", "true");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "GB", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("GB") \
                .local \
                .list(voice_enabled=True)

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("GB").setVoiceEnabled(true).read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/GB/Local.json \
    -d "VoiceEnabled=true" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/GB\/Local.json?VoiceEnabled=true&SmsEnabled=true",
  "available_phone_numbers": [
    {
      "friendly_name": "+442033224780",
      "phone_number": "+442033224780",
      "iso_country": "GB",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/GB/Local?VoiceEnabled=true&SmsEnabled=true">
    <AvailablePhoneNumber>
      <FriendlyName>+442033224780</FriendlyName>
      <PhoneNumber>+442033224780</PhoneNumber>
      <IsoCountry>GB</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
機能を指定した地域電話番号の検索
コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  excludeAllAddressRequired: 'true',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    excludeAllAddressRequired: 'true',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.ExcludeAllAddressRequired = true;

    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);

  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "ExcludeAllAddressRequired" => "true"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(exclude_all_address_required: 'true')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read(
            "US",
            excludeAllAddressRequired: true);

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("excludeAllAddressRequired" => "true")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    exclude_all_address_required="true", type="local", country="US"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').local
                  .list(exclude_all_address_required: 'true')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("ExcludeAllAddressRequired", "true");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(exclude_all_address_required=True)

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setExcludeAllAddressRequired(true).read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "ExcludeAllAddressRequired=true" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?ExcludeAllAddressRequired=true",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 555-1212",
      "phone_number": "+15105551212",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?ExcludeAllAddressRequired=true">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 555-1212</FriendlyName>
      <PhoneNumber>+15105551212</PhoneNumber>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
機能を指定した市内電話番号の検索
コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  excludeLocalAddressRequired: 'true',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    excludeAllAddressRequired: 'true',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.ExcludeLocalAddressRequired = true;

    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);

  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "ExcludeLocalAddressRequired" => "true"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(exclude_local_address_required: 'true')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US",
                                                      excludeLocalAddressRequired: true);

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("excludeLocalAddressRequired" => "true")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    exclude_local_address_required="true", type="local", country="US"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').local
                  .list(exclude_local_address_required: 'true')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("ExcludeLocalAddressRequired", "true");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(exclude_local_address_required=True)

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setExcludeLocalAddressRequired(true).read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "ExcludeLocalAddressRequired=true" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?ExcludeLocalAddressRequired=True",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 555-1212",
      "phone_number": "+15105551212",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?ExcludeLocalAddressRequired=true">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 555-1212</FriendlyName>
      <PhoneNumber>+15105551212</PhoneNumber>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
住所不要の地域別電話番号を検索する

Advanced List Filter Example

These features are limited to US and Canadian phone numbers. Find local phone numbers within 50 miles of San Francisco, CA (37.840699,-122.461853) that contain the digits '555'.

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  nearLatLong: '37.840699,-122.461853',
  distance: '50',
  contains: '555',
  inRegion: 'CA',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    nearLatLong: '37.840699,-122.461853',
    distance: '50',
    contains: '555',
    inRegion: 'CA',
  })
  .then(data => {
    const number = data[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.NearLatLong = "37.840699,-122.461853";
    options.Distance = 50;
    options.Contains = "555";
    options.InRegion = "CA";
    
    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US',
    'Local',
    array(
        "NearLatLong" => "37.840699,-122.461853",
        "Distance" => "50",
        "Contains" => "555",
        "InRegion" => "CA"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];

// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.account.available_phone_numbers
                  .get('US')
                  .local
                  .list(near_lat_long: '37.840699,-122.461853',
                        distance: '50',
                        contains: '555',
                        in_region: 'CA')

# Purchase the number
@number = @numbers[0].phone_number
@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using System.Collections.Generic;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        const string nearLatLong = "37.840699,-122.461853";
        var localAvailableNumbers = LocalResource.Read("US",
                                                      nearLatLong: nearLatLong,
                                                      distance: 50,
                                                      contains: "555",
                                                      inRegion: "CA");

        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);
        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array(
        "nearLatLong" => "37.840699,-122.461853",
        "distance" => "50",
        "contains" => "555",
        "inRegion" => "CA"
    )
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    distance="50",
    near_lat_long="37.840699,-122.461853",
    country="US",
    contains="555",
    in_region="CA",
    type="local"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Retrieve available phone numbers in near specified latitude and longitude
# for the given account sid
@numbers = @client.api.available_phone_numbers('US')
                  .local.list(
                    near_lat_long: '37.840699,-122.461853',
                    distance: '50',
                    contains: '555',
                    in_region: 'CA'
                  )

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    HashMap<String, String> params = new HashMap<String, String>();

    params.put("NearLatLong", "37.840699,-122.461853");
    params.put("Distance", "50");
    params.put("Contains", "555");
    params.put("InRegion", "CA");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(near_lat_long="37.840699,-122.461853",
                      distance="50",
                      contains="555",
                      in_region="CA")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US")
        .setContains("555")
        .setNearLatLong("37.840699,-122.461853")
        .setDistance(50)
        .setInRegion("CA")
        .read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "NearLatLong=37.840699%2C-122.461853" \
    -d "Distance=50" \
    -d "Contains=555" \
    -d "InRegion=CA" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?InRegion=CA&NearLatLong=37.840699,-122.461853&Distance=50&Contains=555",
  "available_phone_numbers": [
    {
      "friendly_name": "(415) 555-1212",
      "phone_number": "+14155551212",
      "lata": "528",
      "rate_center": "SNFC CNTRL",
      "latitude": "37.7726",
      "longitude": "-122.4196",
      "region": "CA",
      "postal_code": "94133",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?InRegion=CA&NearLatLong=37.840699,-122.461853&Distance=50&Contains=555">
    <AvailablePhoneNumber>
      <FriendlyName>(415) 555-1212</FriendlyName>
      <PhoneNumber>+14155551212</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>SNFC CNTRL</RateCenter>
      <Latitude>37.7726</Latitude>
      <Longitude>-122.4196</Longitude>
      <Region>CA</Region>
      <PostalCode>94133</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
複数のパラメーターを指定した市内電話番号の検索

HTTP POST

サポートしません。

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

AvailablePhoneNumbers 無料電話番号リスト サブリソース

リソースURI

/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{IsoCountryCode}/TollFree

{IsoCountryCode} は ISO 3166-1 alpha-2 フォーマット の国コードです (US はアメリカ、CA はカナダ、GB はイギリス)。

HTTP GET

指定したフィルターに一致する無料電話番号の AvailablePhoneNumber 要素のリストを返します。各項目は、ユーザーのアカウントで現在プロビジョニング可能な電話番号を表現します。 電話番号をプロビジョニングするには、電話番号を IncomingPhoneNumber リソースに POST します。

リストフィルター

下記のGETのクエリー文字列パラメーターを使用すると、返される一覧を制限することができます。 パラメーターは大文字と小文字を区別することに注意してください:

名前 概要
AreaCode

Optional. Find phone numbers in the specified area code. (US and Canada only) (🏢 not PII)

ベータ

Optional. Include phone numbers new to the Twilio platform. Possible values are either true or false. Default is true. (🏢 not PII)

Contains

Optional. A pattern on which to match phone numbers. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit. See Example 2 and Example 3 below. NOTE: Patterns must be at least two characters long. (🏢 not PII)

Distance

Optional. Specifies the search radius for a Near- query in miles. If not specified this defaults to 25 miles. Maximum searchable distance is 500 miles. Limited to US and Canadian phone numbers. (🏢 not PII)

ExcludeAllAddressRequired

Optional. Indicates whether the response includes phone numbers which require any Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with an Address required. (🏢 not PII)

ExcludeForeignAddressRequired

Optional. Indicates whether the response includes phone numbers which require a foreign Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with a foreign Address required. (🏢 not PII)

ExcludeLocalAddressRequired

Optional. Indicates whether the response includes phone numbers which require a local Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with a local Address required. (🏢 not PII)

FaxEnabled

Optional. This indicates whether the phone numbers can receive faxes. Possible values are true or false. (🏢 not PII)

InLata

Optional. Limit results to a specific Local access and transport area (LATA). Given a phone number, search within the same LATA as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

InLocality

Optional. Limit results to a particular locality (i.e. City). Given a phone number, search within the same Locality as that number. (🏢 not PII)

InPostalCode

Optional. Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

InRateCenter

Optional. Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well. Limited to US and Canadian phone numbers. (🏢 not PII)

InRegion

Optional. Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

MmsEnabled

Optional. This indicates whether the phone numbers can receive MMS messages. Possible values are true or false. (🏢 not PII)

NearLatLong

Optional. Given a latitude/longitude pair lat,long find geographically close numbers within Distance miles. Limited to US and Canadian phone numbers. (🏢 not PII)

NearNumber

Optional. Given a phone number, find a geographically close number within Distance miles. Distance defaults to 25 miles. Limited to US and Canadian phone numbers. (🏢 not PII)

SmsEnabled

Optional. This indicates whether the phone numbers can receive text messages. Possible values are true or false. (🏢 not PII)

VoiceEnabled

Optional. This indicates whether the phone numbers can receive calls. Possible values are true or false. (🏢 not PII)

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').tollFree.list({}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .tollFree.list()
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    
    var result = twilio.ListAvailableTollFreePhoneNumbers("US");
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'TollFree', array()
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.account.available_phone_numbers.get('US').toll_free.list

# Purchase the number
@number = @numbers[0].phone_number
@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var tollFreeAvailableNumbers = TollFreeResource.Read("US");

        // Purchase the first number on the list
        var firstNumber = tollFreeAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->tollFree->read();

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(country="US", type="tollfree")

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').toll_free.list

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);



    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(new HashMap<String, String>(), "US", "TollFree");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .toll_free \
                .list()

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.TollFree;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<TollFree> numbers = TollFree.reader("US").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/TollFree.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/TollFree.json",
  "available_phone_numbers": [
    {
      "friendly_name": "(866) 583-8815",
      "phone_number": "+18665838815",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
    {
      "friendly_name": "(866) 583-0795",
      "phone_number": "+18665830795",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
    ...
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/TollFree">
    <AvailablePhoneNumber>
      <FriendlyName>(866) 583-8815</FriendlyName>
      <PhoneNumber>+18665838815</PhoneNumber>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
    <AvailablePhoneNumber>
      <FriendlyName>(866) 583-0795</FriendlyName>
      <PhoneNumber>+18665830795</PhoneNumber>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
    ...
  </AvailablePhoneNumbers>
</TwilioResponse>
任意の着課金方式(Tollfree)電話番号の検索

文字列を指定した着課金方式電話番号の検索

指定した数字列を含む電話番号を検索します。Contains=866 とすると、数字の 866 を含む着課金方式電話番号がマッチします。866-555-3455 や 888-866-0555 などです。Contains=866***EPIC とすると、数字の 866 で始まり、その後に任意の 3 桁の数字、さらに数字の 3742 (「EPIC」) が続く番号がマッチします。 パターン「STORM」にマッチする着課金方式電話番号を検索する場合は、次のリクエストを発行します。

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').tollFree.list({
  contains: 'STORM',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .tollFree.list({
    contains: 'STORM',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.Contains = "STORM";
    
    var result = twilio.ListAvailableTollFreePhoneNumbers("US", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'TollFree', array(
        "Contains" => "STORM"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .toll_free.list(contains: 'STORM')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var tollFreeAvailableNumbers = TollFreeResource.Read("US", contains: "STORM");

        // Purchase the first number on the list
        var firstNumber = tollFreeAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->tollFree->read(
    array("contains" => "STORM")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="US", contains="STORM", type="tollfree"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').toll_free
                  .list(contains: 'STORM')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("Contains", "STORM");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "TollFree");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .toll_free \
                .list(contains="STORM")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.TollFree;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<TollFree> numbers = TollFree.reader("US").setContains("STORM").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/TollFree.json \
    -d "Contains=STORM" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/TollFree.json?Contains=STORM",
  "available_phone_numbers": [
    {
      "friendly_name": "(866) 557-8676",
      "phone_number": "+18665578676",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/TollFree?Contains=STORM">
    <AvailablePhoneNumber>
      <FriendlyName>(866) 557-8676</FriendlyName>
      <PhoneNumber>+18665578676</PhoneNumber>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
文字列を指定した着課金方式電話番号の検索

パターンを指定した無料番号の検索

800 エリアコードでパターン 'KYLO' を含む着課金方式電話番号の検索

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').tollFree.list({
  areaCode: '800',
  contains: 'KYLO',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .tollFree.list({
    areaCode: '800',
    contains: 'KYLO',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.AreaCode = "800";
    options.Contains = "KYLO";
    
    var result = twilio.ListAvailableTollFreePhoneNumbers("US", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'TollFree', array(
        "AreaCode" => "800",
        "Contains" => "KYLO"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers
                .get('US')
                .toll_free
                .list(area_code: '800', contains: 'KYLO')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var tollFreeAvailableNumbers = TollFreeResource.Read("US",
                                                        areaCode: 800,
                                                        contains: "STORM");

        // Purchase the first number on the list
        var firstNumber = tollFreeAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->tollFree->read(
    array("contains" => "KYLO", "areaCode" => "800")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    area_code="800", country="US", contains="KYLO", type="tollfree"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').toll_free
                  .list(area_code: '800', contains: 'KYLO')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("AreaCode", "800");
    params.put("Contains", "KYLO");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "TollFree");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .toll_free \
                .list(contains="KYLO", area_code="800")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.TollFree;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<TollFree> numbers =
        TollFree.reader("US").setContains("KYLO").setAreaCode(800).read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/TollFree.json \
    -d "AreaCode=800" \
    -d "Contains=KYLO" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/TollFree.json?AreaCode=800&Contains=KYLO",
  "available_phone_numbers": [
    {
      "friendly_name": "(800) 945-3669",
      "phone_number": "+18009453669",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/TollFree?AreaCode=800&Contains=KYLO">
    <AvailablePhoneNumber>
      <FriendlyName>(800) 945-3669</FriendlyName>
      <PhoneNumber>+18009453669</PhoneNumber>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
パターンを指定した着課金方式電話番号の検索

HTTP POST

サポートしません。

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

AvailablePhoneNumbers 携帯電話リストサブリソース

リソースURI

/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{IsoCountryCode}/Mobile

{IsoCountryCode} は ISO 3166-1 alpha-2 フォーマットの国コードです。たとえば、カナダの ISO 国コードは CA です。 サポート対象国 の国名と Twilio がサポートする IsoCountryCode の完全なリストを参照してください。

HTTP GET

フィルターにマッチした携帯電話AvailablePhoneNumberリソースが返されます。あなたのアカウントで有効な電話番号が表示されませす。

リストフィルター

以下のGETクエリーは電話番号のリストを返します。注意 : パラメーターは大文字、小文字を区別します。

名前 概要
AreaCode

Optional. Find phone numbers in the specified area code. (US and Canada only) (🏢 not PII)

ベータ

Optional. Include phone numbers new to the Twilio platform. Possible values are either true or false. Default is true. (🏢 not PII)

Contains

Optional. A pattern on which to match phone numbers. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit. See Example 2 and Example 3 below. NOTE: Patterns must be at least two characters long. (🏢 not PII)

Distance

Optional. Specifies the search radius for a Near- query in miles. If not specified this defaults to 25 miles. Maximum searchable distance is 500 miles. Limited to US and Canadian phone numbers. (🏢 not PII)

ExcludeAllAddressRequired

Optional. Indicates whether the response includes phone numbers which require any Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with an Address required. (🏢 not PII)

ExcludeForeignAddressRequired

Optional. Indicates whether the response includes phone numbers which require a foreign Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with a foreign Address required. (🏢 not PII)

ExcludeLocalAddressRequired

Optional. Indicates whether the response includes phone numbers which require a local Address. Possible values are true or false. If not specified, the default is false, and results could include phone numbers with a local Address required. (🏢 not PII)

FaxEnabled

Optional. This indicates whether the phone numbers can receive faxes. Possible values are true or false. (🏢 not PII)

InLata

Optional. Limit results to a specific Local access and transport area (LATA). Given a phone number, search within the same LATA as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

InLocality

Optional. Limit results to a particular locality (i.e. City). Given a phone number, search within the same Locality as that number. (🏢 not PII)

InPostalCode

Optional. Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

InRateCenter

Optional. Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well. Limited to US and Canadian phone numbers. (🏢 not PII)

InRegion

Optional. Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number. Limited to US and Canadian phone numbers. (🏢 not PII)

MmsEnabled

Optional. This indicates whether the phone numbers can receive MMS messages. Possible values are true or false. (🏢 not PII)

NearLatLong

Optional. Given a latitude/longitude pair lat,long find geographically close numbers within Distance miles. Limited to US and Canadian phone numbers. (🏢 not PII)

NearNumber

Optional. Given a phone number, find a geographically close number within Distance miles. Distance defaults to 25 miles. Limited to US and Canadian phone numbers. (🏢 not PII)

SmsEnabled

Optional. This indicates whether the phone numbers can receive text messages. Possible values are true or false. (🏢 not PII)

VoiceEnabled

Optional. This indicates whether the phone numbers can receive calls. Possible values are true or false. (🏢 not PII)

携帯電話番号の検索

イギリスの携帯電話を探してみましょう

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('GB').mobile.list({}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('GB')
  .mobile.list()
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    var result = twilio.ListAvailableMobilePhoneNumbers("GB", options);

    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);

  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'GB', 'Mobile', array()
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.account.available_phone_numbers.get('GB').mobile.list

# Purchase the number
@number = @numbers[0].phone_number
@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var mobileAvailableNumbers = MobileResource.Read("GB");

        // Purchase the first number on the list
        var firstNumber = mobileAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('GB')->mobile->read();

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(country="GB", type="mobile")

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('GB').mobile.list

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("GB") \
                .mobile \
                .list()

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Mobile;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Mobile> numbers = Mobile.reader("GB").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/GB/Mobile.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/GB\/Mobile.json",
  "available_phone_numbers": [
    {
      "friendly_name": "+447903501715",
      "phone_number": "+447903501715",
      "lata": null,
      "rate_center": null,
      "latitude": null,
      "longitude": null,
      "region": "Clacton-on-Sea",
      "postal_code": null,
      "iso_country": "GB",
      "capabilities":{
        "voice": false,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
    ...
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/GB/Mobile">
    <AvailablePhoneNumber>
      <FriendlyName>+447903501715</FriendlyName>
      <PhoneNumber>+447903501715</PhoneNumber>
      <Lata/>
      <RateCenter/>
      <Latitude/>
      <Longitude/>
      <Region>Clacton-on-Sea</Region>
      <PostalCode>/>
      <IsoCountry>GB</IsoCountry>
      <Capabilities>
        <Voice>false</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
    ...
  </AvailablePhoneNumbers>
</TwilioResponse>
地域を指定した携帯電話番号の検索

HTTP POST

サポートしません。

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

サポートされる国とタイプ

リソースURI

/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers

HTTP GET

アカウントに所属する AvailablePhoneNumber サブリソースをISO国順にリストを返します。全ての番号の情報が必要な場合電話番号 CSVもしくはFAQをご覧ください。

名前 概要
account_sid

The 34 character string that uniquely identifies your account. (🏢 not PII)

ベータ

If true, all phone numbers available in this country are new to the Twilio platform. If false, all numbers are not in the Twilio Phone Number Beta program. (🏢 not PII)

country_code

The ISO Country code to lookup phone numbers for. (🏢 not PII)

リストフィルター

AvailablePhoneNumbers 国リストは下記のパラメーターでフィルターできます。

パラメーター 概要
ベータ もし trueの場合、新しい番号が追加された国のみを含めます。falseの場合は、新しい番号は含まれません。

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

コードサンプルを読み込んでいます...
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  areaCode: '510',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

// Find and then purchase a phone number
client
  .availablePhoneNumbers('US')
  .local.list({
    areaCode: '510',
  })
  .then(data => {
    const number = data[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.AreaCode = "510";
    
    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "AreaCode" => "510"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];

// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(area_code: '510')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US", areaCode: 510);

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("areaCode" => "510")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    area_code="510", country="US", type="local"
)
# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
client = Twilio::REST::Client.new(account_sid, auth_token)

# Retrieve available phone numbers in near specified latitude and longitude
# for the given account sid
numbers = client.api.available_phone_numbers('US')
                .local.list(area_code: '510')

number = numbers[0].phone_number

client.incoming_phone_numbers.create(phone_number: number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("AreaCode", "510");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(area_code="510")

# Purchase the phone number
number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setAreaCode(510).read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "AreaCode=510" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?AreaCode=510",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 564-7903",
      "phone_number": "+15105647903",
      "lata": "722",
      "rate_center": "OKLD TRNID",
      "latitude": "37.780000",
      "longitude": "-122.380000",
      "region": "CA",
      "postal_code": "94703",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
    {
      "friendly_name": "(510) 488-4379",
      "phone_number": "+15104884379",
      "lata": "722",
      "rate_center": "OKLD FRTVL",
      "latitude": "37.780000",
      "longitude": "-122.380000",
      "region": "CA",
      "postal_code": "94602",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    },
    ...
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?AreaCode=510">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 564-7903</FriendlyName>
      <PhoneNumber>+15105647903</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>OKLD TRNID</RateCenter>
      <Latitude>37.780000</Latitude>
      <Longitude>-122.380000</Longitude>
      <Region>CA</Region>
      <PostalCode>94703</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
    <AvailablePhoneNumber>
      <FriendlyName>(510) 488-4379</FriendlyName>
      <PhoneNumber>+15104884379</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>OKLD FRTVL</RateCenter>
      <Latitude>37.780000</Latitude>
      <Longitude>-122.380000</Longitude>
      <Region>CA</Region>
      <PostalCode>94602</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
    ...
  </AvailablePhoneNumbers>
</TwilioResponse>
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  contains: '510555****',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    contains: '510555****',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.Contains = "510555****";
    
    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList('US', 'Local', array(
        "Contains" => "510555****"
    ));

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(contains: '510555****')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US",
                                                      contains: "510555****");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("contains" => "510555****")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="US", contains="510555****", type="local"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Retrieve available phone numbers that match the given pattern
@numbers = @client.api.available_phone_numbers('US').local
                  .list(contains: '510555****')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("Contains", "510555****");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(contains="510555****")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setContains("510555****").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "Contains=510555****" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?Contains=510555****",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 555-1214",
      "phone_number": "+15105551214",
      "lata": "722",
      "rate_center": "OKLD0349T",
      "latitude": "37.806940",
      "longitude": "-122.270360",
      "region": "CA",
      "postal_code": "94612",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?Contains=510555****">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 555-1214</FriendlyName>
      <PhoneNumber>+15105551214</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>OKLD0349T</RateCenter>
      <Latitude>37.806940</Latitude>
      <Longitude>-122.270360</Longitude>
      <Region>CA</Region>
      <PostalCode>94612</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  contains: 'STORM',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    contains: 'STORM',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.Contains = "STORM";

    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "Contains" => "STORM"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(contains: 'STORM')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US", contains: "STORM");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);

        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("contains" => "STORM")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="US", contains="STORM", type="local"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').local
                  .list(contains: 'STORM')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("Contains", "STORM");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(contains="STORM")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setContains("STORM").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "Contains=STORM" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?Contains=STORM",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 557-8676",
      "phone_number": "+15105578678",
      "lata": "722",
      "rate_center": "FRNK MAIN",
      "latitude": "37.557",
      "longitude": "-122.0073",
      "region": "CA",
      "postal_code": "94560",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?Contains=STORM">
    <AvailablePhoneNumber>
      <FriendlyName>(510) 557-8676</FriendlyName>
      <PhoneNumber>+15105578676</PhoneNumber>
      <Lata>722</Lata>
      <RateCenter>FRNK MAIN</RateCenter>
      <Latitude>37.557</Latitude>
      <Longitude>-122.0073</Longitude>
      <Region>CA</Region>
      <PostalCode>94560</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('US').local.list({
  inRegion: 'AR',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('US')
  .local.list({
    inRegion: 'AR',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.InRegion = "AR";

    var result = twilio.ListAvailableLocalPhoneNumbers("US", options);

    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;

    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'US', 'Local', array(
        "InRegion" => "AR"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('US')
                .local.list(in_region: 'AR')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("US", inRegion: "AR");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);
        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("inRegion" => "AR")
);

// Purchase the first number on the list.
$number = $client->incomingPhoneNumbers
    ->create(
        array(
            "phoneNumber" => $numbers[0]->phoneNumber
        )
    );

echo $number->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

numbers = client.phone_numbers.search(
    country="US", type="local", in_region="AR"
)

# Purchase the first number in the list
if numbers:
    numbers[0].purchase()
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@numbers = @client.api.available_phone_numbers('US').local
                  .list(in_region: 'AR')

@number = @numbers[0].phone_number

@client.incoming_phone_numbers.create(phone_number: @number)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.AvailablePhoneNumber;
import com.twilio.sdk.resource.list.AvailablePhoneNumberList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AvailablePhoneNumberList
    Map<String, String> params = new HashMap<String, String>();

    params.put("InRegion", "AR");

    AvailablePhoneNumberList numbers = client.getAccount().getAvailablePhoneNumbers(params, "US", "Local");
    List<AvailablePhoneNumber> list = numbers.getPageData();

    // Purchase the first number on the list.
    List<NameValuePair> purchaseParams = new ArrayList<NameValuePair>();
    purchaseParams.add(new BasicNameValuePair("PhoneNumber", list.get(0).getPhoneNumber()));
    client.getAccount().getIncomingPhoneNumberFactory().create(purchaseParams);
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

numbers = client.available_phone_numbers("US") \
                .local \
                .list(in_region="AR")

number = client.incoming_phone_numbers \
               .create(phone_number=numbers[0].phone_number)

print(number.sid)
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Local> numbers = Local.reader("US").setInRegion("AR").read();

    // Purchase the first number on the list.
    PhoneNumber availableNumber = numbers.iterator().next().getPhoneNumber();

    IncomingPhoneNumber.creator(availableNumber).create();
  }
}
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
    -d "InRegion=AR" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/AvailablePhoneNumbers\/US\/Local.json?InRegion=AR",
  "available_phone_numbers": [
    {
      "friendly_name": "(510) 555-1212",
      "phone_number": "+15105551212",
      "lata": "528",
      "rate_center": "LITTLEROCK",
      "latitude": "34.7556",
      "longitude": "-92.318",
      "region": "AR",
      "postal_code": "72205",
      "iso_country": "US",
      "capabilities":{
        "voice": true,
        "SMS": true,
        "MMS": false
      },
      "beta": false
    }
  ]
}
<TwilioResponse>
  <AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local?InRegion=AR">
    <AvailablePhoneNumber>
      <FriendlyName>(501) 555-1212</FriendlyName>
      <PhoneNumber>+15015551212</PhoneNumber>
      <Lata>528</Lata>
      <RateCenter>LITTLEROCK</RateCenter>
      <Latitude>34.7556</Latitude>
      <Longitude>-92.318</Longitude>
      <Region>AR</Region>
      <PostalCode>72205</PostalCode>
      <IsoCountry>US</IsoCountry>
      <Capabilities>
        <Voice>true</Voice>
        <SMS>true</SMS>
        <MMS>false</SMS>
      </Capabilities>
      <Beta>false</Beta>
    </AvailablePhoneNumber>
  </AvailablePhoneNumbers>
</TwilioResponse>
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
  • XML
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers('GB').local.list({
  contains: ' 4420',
}, (err, data) => {
  const number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create(
    {
      phoneNumber: number.phone_number,
    },
    (err, purchasedNumber) => {
      console.log(purchasedNumber.sid);
    }
  );
});
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client
  .availablePhoneNumbers('GB')
  .local.list({
    contains: ' 4420',
  })
  .then(availablePhoneNumbers => {
    const number = availablePhoneNumbers[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then(purchasedNumber => console.log(purchasedNumber.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var options = new AvailablePhoneNumberListRequest();
    options.Contains = " 4420";
    
    var result = twilio.ListAvailableLocalPhoneNumbers("GB", options);
    
    // Purchase the first number on the list
    var availableNumber = result.AvailablePhoneNumbers[0];
    var purchaseOptions = new PhoneNumberOptions();
    purchaseOptions.PhoneNumber = availableNumber.PhoneNumber;
    
    var number = twilio.AddIncomingPhoneNumber(purchaseOptions);
    Console.WriteLine(number.Sid);
    
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList(
    'GB', 'Local', array(
        "Contains" => " 4420"
    )
);

$firstNumber = $numbers->available_phone_numbers[0];
// Purchase the first number on the list.
$twilioNumber = $client->account->incoming_phone_numbers->create(
    array(
        "PhoneNumber" => $firstNumber->phone_number
    )
);

echo $twilioNumber->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::Client.new(account_sid, auth_token)

numbers = client.account
                .available_phone_numbers.get('GB')
                .local.list(contains: ' 4420')

# Purchase the number
number = numbers[0].phone_number
client.account.incoming_phone_numbers.create(phone_number: number)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Rest.Api.V2010.Account.AvailablePhoneNumberCountry;
using System.Linq;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var localAvailableNumbers = LocalResource.Read("GB",
                                                      contains: " 4420");

        // Purchase the first number on the list
        var firstNumber = localAvailableNumbers.First();
        var incomingPhoneNumber = IncomingPhoneNumberResource.Create(
            phoneNumber: firstNumber.PhoneNumber);
        Console.WriteLine(incomingPhoneNumber.Sid);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libra