REST API: 利用可能電話番号

AvailablePhoneNumbersのサブリソースは、購入可能なローカル番号、フリーダイヤル、携帯電話番号を探し出すことができます。国名、エリアコード(NPA)、エクスチェンジ(NXX)、特定の地域からパターンマッチを使って電話場嵌合を探し出すことができます。

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

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

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

リソース URI

AvailablePhoneNumber 国内番号 インスタンス リソースには、URI はありません。 AvailablePhoneNumber インスタンス リソースに直接リクエストを発行することはできません。 国内番号リスト サブリソース にリクエストを発行し、リストから番号を選択してください。

リソースのプロパティ

アメリカとカナダの電話番号には、次のプロパティがあります。

プロパティ 説明
FriendlyName 電話番号のわかりやすい表記です。
PhoneNumber E.164 (「+国番号」付き) フォーマットの電話番号です。
Lata この電話番号の LATA です。
RateCenter この電話番号の 料金センター です。
Latitude この電話番号の緯度座標です。
Longitude この電話番号の経度座標です。
Region この電話番号の州名コード (2 文字) です。
PostalCode この電話番号の郵便番号 (ZIP コード) です。
IsoCountry この電話番号の ISO 国コード です。
利用可能な機能 電話番号が電話、メッセージを受信できるかどうかを示します有力な候補はVoiceSMSMMSで、それらはtrueもしくはfalseの値を持ちます。
AddressRequirements 意味することは、電話番号があなた、もしくはあなたのお客様が住所をTwilioに登録する必要かあるかどうかを示します。取りうる値はnoneanylocalもしくはforeignです。
ベータ ベータステータスの電話番号フラグ取りうる値は true もしくは false.

アメリカとカナダ以外の電話番号には、次のプロパティがあります。

プロパティ 説明
FriendlyName 電話番号のわかりやすい表記です。
PhoneNumber E.164 (「+国番号」付き) フォーマットの電話番号です。
IsoCountry この電話番号の ISO 国コード です。
利用可能な機能 電話番号が電話、メッセージを受信できるかどうかを示します有力な候補はVoiceSMSMMSで、それらはtrueもしくはfalseの値を持ちます。
AddressRequirements 意味することは、電話番号があなた、もしくはあなたのお客様が住所をTwilioに登録する必要かあるかどうかを示します。取りうる値はnoneanylocalもしくはforeignです。
ベータ ベータステータスの電話番号フラグ取りうる値は true もしくは false.

アドレス要件値

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

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

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

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

リソース URI

AvailablePhoneNumber の無料電話番号インスタンス リソースには、URI はありません。 AvailablePhoneNumber インスタンス リソースに直接リクエストを発行することはできません。 無料電話番号リスト サブリソース にリクエストを発行し、リストから番号を選択してください。

リソースのプロパティ

プロパティ 説明
FriendlyName 電話番号のわかりやすい表記です。
PhoneNumber E.164 (「+国番号」付き) フォーマットの電話番号です。
IsoCountry この電話番号の ISO 国コード です。
利用可能な機能 電話番号が電話、メッセージを受信できるかどうかを示します有力な候補はVoiceSMSMMSで、それらはtrueもしくはfalseの値を持ちます。
AddressRequirements 意味することは、電話番号があなた、もしくはあなたのお客様が住所をTwilioに登録する必要かあるかどうかを示します。取りうる値はnoneanylocalもしくはforeignです。

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

リソース URI

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

リソースのプロパティ

プロパティ 説明
FriendlyName 電話番号のわかりやすい表記です。
PhoneNumber E.164 (「+国番号」付き) フォーマットの電話番号です。
IsoCountry この電話番号の ISO 国コード です。
利用可能な機能 電話番号が電話、メッセージを受信できるかどうかを示します有力な候補はVoiceSMSMMSで、それらはtrueもしくはfalseの値を持ちます。
AddressRequirements 意味することは、電話番号があなた、もしくはあなたのお客様が住所をTwilioに登録する必要かあるかどうかを示します。取りうる値はnoneanylocalもしくはforeignです。

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 指定のエリア コードの電話番号を検索します。
Contains 電話番号のパターンマッチを有効にします。有効な文字は'*' もしくは [0-9a-zA-Z]です。'*' は一桁のどんな文字にもマッチします。下記の 例2例3 を御覧ください。
SmsEnabled 電話番号がSMSを受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
MmsEnabled 電話番号がMMSを受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
VoiceEnabled 電話番号が電話を受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
ExcludeAllAddressRequired 住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値はtrueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果は住所が必要な電話番号を含みます。
ExcludeLocalAddressRequired ローカルな住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値はtrueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果はローカルの住所が必要な電話番号を含みます。
ExcludeForeignAddressRequired 外国の住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値は、trueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果は外国の住所が必要な電話番号を含みます。
ベータ 提供されたばかりのベータの電話番号を含める取りうる値は true もしくは false。デフォルトは true.

電話番号の検索と購入

AvailablePhoneNumbers のルックアップと IncomingPhoneNumbers の購入を組み合わせることによって、さまざまな検索条件を使用して任意の番号を購入できます。いくつか例を挙げると、特定のパターンに一致している、特定の地域にある、または他の番号に近い、といった購入可能な番号を検索できます。購入したい番号が見つかったら、その番号を IncomingPhoneNumbers リソースに POST するだけです。

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

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

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local.list(area_code: '510')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  areaCode: "510"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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({
    areaCode: '510',
  })
  .then((data) => {
    const number = data[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then((purchasedNumber) => console.log(purchasedNumber.sid));
// 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")

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

print(number.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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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 で始まる購入可能な番号を検索します。

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(contains: '510555****')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  contains: "510555****"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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」に一致する国内電話番号を検索します。

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(contains: 'STORM')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  contains: "STORM"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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>
パターンによる電話番号の検索

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

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

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(in_region: 'AR')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  inRegion: "AR"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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)を探してみましょう

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(contains: '4420')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("GB").local.list({
  contains: " 4420"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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が有効な電話番号を探してみましょう

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('GB').local
                  .list(voice_enabled: 'true')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("GB").local.list({
  voiceEnabled: "true"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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>
機能を指定した地域電話番号の検索
Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(exclude_all_address_required: 'true')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  excludeAllAddressRequired: "true"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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>
機能を指定した市内電話番号の検索
Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(exclude_local_address_required: 'true')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  excludeLocalAddressRequired: "true"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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>
住所不要の地域別電話番号を検索する

高度なリスト フィルター

次の高度な GET クエリ パラメーターを使って、いくつかの方法で返却されるリストに制限を加えます。 この機能は、アメリカとカナダの電話番号のみ使用できます。

パラメーター 説明
NearNumber ここで指定する電話番号から、Distance で設定された距離 (マイル) の範囲内にある近隣エリアの番号を検索します。 Distance の初期値は 25 マイルです。
NearLatLong 与えられた緯度、経度(lat,long)情報から地理的にどれくらいのマイル(Distance)以内にあるか調べます。
Distance Near-クエリで使用する検索範囲の半径を、マイルで指定します。 指定しない場合、初期値は 25 マイル(40km)です。最大半径は500マイル(約800km)です。
InPostalCode 郵便番号で結果を絞ります。郵便番号に該当する電話番号を探し出します。
InRegion 特定の地域の番号に結果を絞ります(例 : 州、省)同じ地域に所属する電話番号を探し出します。
InRateCenter 検索結果をここで指定する料金センターに限定します。または、電話番号を指定すると、この番号と同一の料金センターの中から検索します。 InLata も併せてセットする必要があります。
InLata 検索結果を指定の通話サービス区域 (LATA) に限定します。 電話番号を指定すると、この番号と同一の LATA の中から検索します。

カリフォルニア州サンフランシスコ (37.840699、-122.461853) から 50 マイルの範囲内で、「555」を含む国内番号を検索します。

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.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.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

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

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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 指定のエリア コードの電話番号を検索します。
Contains 電話番号のパターンマッチを有効にします。有効な文字は '*'もしくは[0-9a-zA-Z]です。'*'は一桁のどんな文字にもマッチします。下記の 例2 を御覧ください。
SmsEnabled 電話番号がSMSを受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
MmsEnabled 電話番号がMMSを受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
VoiceEnabled 電話番号が電話を受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
ExcludeAllAddressRequired 住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値はtrueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果は住所が必要な電話番号を含みます。
ExcludeLocalAddressRequired ローカルな住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値はtrueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果はローカルの住所が必要な電話番号を含みます。
ExcludeForeignAddressRequired 外国の住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値は、trueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果は外国の住所が必要な電話番号を含みます。
ベータ 提供されたばかりのベータの電話番号を含める取りうる値は true もしくは false。デフォルトは true.

任意の無料電話番号の検索

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').toll_free.list

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").tollFree.list({}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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>
任意の無料電話番号の検索

文字列を指定した無料番号の検索

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

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').toll_free
                  .list(contains: 'STORM')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").tollFree.list({
  contains: "STORM"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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' を含む無料電話番号の検索

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').toll_free
                  .list(area_code: '800', contains: 'KYLO')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

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

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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クエリーは電話番号のリストを返します。注意 : パラメーターは大文字、小文字を区別します。

パラメーター 説明
Contains 電話番号をマッチするためのパターンです。有効な文字列は'*'[0-9a-zA-Z]です。'*'は1桁のどんな文字でも良いことを示します。例 2をご覧下さい。
SmsEnabled 電話番号がSMSを受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
MmsEnabled 電話番号がMMSを受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
VoiceEnabled 電話番号が電話を受信できるかどうかを示します可能な場合はtrue、そうでない場合はfalse
ExcludeAllAddressRequired 住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値はtrueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果は住所が必要な電話番号を含みます。
ExcludeLocalAddressRequired ローカルな住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値はtrueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果はローカルの住所が必要な電話番号を含みます。
ExcludeForeignAddressRequired 外国の住所が必要な電話番号を含むレスポンスが含まれているかどうか示します。取りうる値は、trueもしくはfalseです。値が指定されない場合デフォルトはfalseです。結果は外国の住所が必要な電話番号を含みます。
ベータ 提供されたばかりのベータの電話番号を含める取りうる値は true もしくは false。デフォルトは true.

携帯電話番号の検索

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

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('GB').mobile.list

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("GB").mobile.list({}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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をご覧ください。

プロパティ 説明
CountryCode ISO国コードを示します
国の正式名称
ベータ もし trueの場合, この国で有効な電話番号は新しくTwilioに追加された番号です。もし falseの場合, 全ての番号はベータではありません。

リスト フィルター

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

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

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

1 / 1
Loading Code Samples...
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local.list(area_code: '510')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  areaCode: "510"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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({
    areaCode: '510',
  })
  .then((data) => {
    const number = data[0];
    return client.incomingPhoneNumbers.create({
      phoneNumber: number.phoneNumber,
    });
  })
  .then((purchasedNumber) => console.log(purchasedNumber.sid));
// 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")

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

print(number.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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(contains: '510555****')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  contains: "510555****"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(contains: 'STORM')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  contains: "STORM"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(in_region: 'AR')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("US").local.list({
  inRegion: "AR"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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
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 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 twilio.com/docs/php/install
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.account.available_phone_numbers('US').local
                  .list(contains: '4420')

@number = @numbers[0].phone_number

@client.account.incoming_phone_numbers.create(phone_number: @number)
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.availablePhoneNumbers("GB").local.list({
  contains: " 4420"
}, function(err, data) {
  var number = data.availablePhoneNumbers[0];

  client.incomingPhoneNumbers.create({
    phoneNumber: number.phone_number
  }, function(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));
// 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)
// 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 twilio.com/docs/php/install
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 'rubygems'          # This line not needed for ruby > 1.8
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)
// 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>
SDKバージョン:
  • 4.x
  • 5.x
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 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 twilio.com/docs/php/install
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