REST API: SMS メッセージ

SMS Message リソースは廃止される予定で、Messageリソースに置き換えられます。将来TwilioAPIから削除される可能性があります。

MessageリソースはSMS/メッセージの上位に位置します。今後はMessageリソースをご利用ください。

SMS Message インスタンス リソースは、着信または発信の SMS メッセージを表現します。 Twilio 番号に SMS メッセージが送信されるか、または REST API か <Sms> 動詞を使って SMS を送信すると、Twilio は SMS Message インスタンス リソースを生成し、アカウントに関連付けます。

SMS Messages リスト リソースは、アカウントから送信したか、またはアカウント宛に送信された SMS メッセージのセットを表現します。

SMS Message インスタンス リソース

このリソースは、個々の SMS メッセージを表現します。

リソース URI

/2010-04-01/Accounts/{AccountSid}/SMS/Messages/{SMSMessageSid}

リソースのプロパティ

SMS Message リソースには、次のプロパティがあります。

プロパティ 説明
Sid このリソースを一意に識別する 34 文字の文字列です。
DateCreated このリソースが生成された日付です。 RFC 2822 フォーマットを使用します。
DateUpdated このリソースが最後に更新された日付です。 RFC 2822 フォーマットを使用します。
DateSent この SMS が送信された日付です。 着信メッセージの場合、この日付は Twilio が SMS を受信した日付になります。 RFC 2822 フォーマットを使用します。
AccountSid この SMS メッセージを送信した アカウント のユニーク ID です。
From このメッセージを送信した電話番号 ( E.164 フォーマット) です。 着信メッセージの場合は、相手の電話番号です。 発信メッセージの場合は、自分の Twilio 番号です。
To このメッセージを受信した電話番号 ( E.164 フォーマット) です。 着信メッセージの場合は、自分の Twilio 番号です。 着信メッセージの場合は、相手の電話番号です。
Body SMS メッセージのテキスト本文です。 テキスト長は 160 文字までです。
Status この SMS メッセージの状態です。 queuedsendingsentfailedreceived のいずれかになります。
Direction この SMS メッセージの方向です。着信メッセージの場合は inbound、REST API で送信したメッセージの場合は outbound-api、通話中に発信されたメッセージの場合は outbound-call、着信メッセージへの返信として発信されたメッセージの場合は outbound-reply となります。
Price このメッセージに対する請求金額です。ご利用のアカウントに紐付いた通貨での額面で示されます。
PriceUnit Price で示される額面の通貨単位です。ISO4127形式です。

(例:usd, eur, jpy).
ApiVersion この SMS メッセージの処理に使用する Twilio API のバージョンです。
Uri URIリソース、右に関連する https://api.twilio.com
SMS ステータス値

Status パラメーターには以下の値を設定できます。

Status 説明
queued SMS メッセージを送信するための API リクエストが成功し、メッセージは送信キューに入りました。
sending Twilio は SMS ネットワークの最寄りの上りキャリアへメッセージを発信中です。
sent メッセージは最寄りの上りキャリアへ送信され、キャリアはメッセージを受け付けました。
failed メッセージを送信できませんでした。通常は、To に指定された番号が存在しません。
received 着信メッセージのみに使用されます。 ユーザーの Twilio 番号 のいずれかで、メッセージを受信しました。

HTTP GET

{SMSMessageSid} で指定した SMS メッセージを返します。

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
  • xml
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;

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 message = MessageResource.Fetch("SM800f449d0399ed014aae2bcc0cc2f2ec");

        Console.WriteLine(message.Body);
    }
}
<?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);

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$sms = $client
    ->messages("SM800f449d0399ed014aae2bcc0cc2f2ec")
    ->fetch();

echo $sms->body;
# 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)

sms = client.sms.messages.get("SM800f449d0399ed014aae2bcc0cc2f2ec")
print(sms.body)
# 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/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
message = @client.account.messages("SM800f449d0399ed014aae2bcc0cc2f2ec").fetch
puts message.body
// 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.sms.messages("SM800f449d0399ed014aae2bcc0cc2f2ec").get(function(err, sms) {
    console.log(sms.body);
});
// Download the Node helper library from twilio.com/docs/node/install
// These consts 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.messages('SM800f449d0399ed014aae2bcc0cc2f2ec')
  .fetch()
  .then((sms) => console.log(sms.body));
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// 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.Sms;

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);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Sms sms = client.getAccount().getSms("SM800f449d0399ed014aae2bcc0cc2f2ec");
    System.out.println(sms.getBody());
    
  }
}
# 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)

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
sms = client.messages("SM800f449d0399ed014aae2bcc0cc2f2ec") \
            .fetch()

print(sms.body)
// 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 sms = twilio.GetSmsMessage("SM800f449d0399ed014aae2bcc0cc2f2ec");
    
    Console.WriteLine(sms.Body);
  }
}
<?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);

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$sms = $client->account->sms_messages->get("SM800f449d0399ed014aae2bcc0cc2f2ec");
echo $sms->body;
# 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

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@sms = @client.account.sms.messages.get("SM800f449d0399ed014aae2bcc0cc2f2ec")
puts @sms.body
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;

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);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Message sms = Message.fetcher("SM800f449d0399ed014aae2bcc0cc2f2ec").fetch();

    System.out.println(sms.getBody());
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
	"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"api_version": "2008-08-01",
	"body": "Hey Jenny why aren't you returning my calls?",
	"date_created": "Mon, 16 Aug 2010 03:45:01 +0000",
	"date_sent": "Mon, 16 Aug 2010 03:45:03 +0000",
	"date_updated": "Mon, 16 Aug 2010 03:45:03 +0000",
	"direction": "outbound-api",
	"from": "+14158141829",
	"price": "-0.02000",
	"sid": "SM800f449d0399ed014aae2bcc0cc2f2ec",
	"status": "sent",
	"to": "+14159978453",
	"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json"
}
<TwilioResponse>
	<SMSMessage>
		<Sid>SM800f449d0399ed014aae2bcc0cc2f2ec</Sid>
		<DateCreated>Mon, 16 Aug 2010 03:45:01 +0000</DateCreated>
		<DateUpdated>Mon, 16 Aug 2010 03:45:03 +0000</DateUpdated>
		<DateSent>Mon, 16 Aug 2010 03:45:03 +0000</DateSent>
		<AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
		<To>+14159978453</To>
		<From>+14158141829</From>
		<Body>Hey Jenny why aren't you returning my calls?</Body>
		<Status>sent</Status>
		<Direction>outbound-api</Direction>
		<ApiVersion>2010-04-01</ApiVersion>
		<Price>-0.02000</Price>
		<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec</Uri>
	</SMSMessage>
</TwilioResponse>
SMS の取得

HTTP POST

サポートしません。

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

SMS Messages リスト リソース

リソース URI

/2010-04-01/Accounts/{AccountSid}/SMS/Messages

HTTP GET

ユーザーのアカウントに関連付けられた SMS メッセージの一覧を返します。 このリストは ページ情報を含みます。ページ情報は DateSent パラメーターでソートされ、最も新しいメッセージが先頭になります。

リスト フィルター

リストを取得するリソースにクエリ パラメーターを指定して、リストに制限を加えます。 パラメーターの大文字と小文字は区別されます。

パラメーター 説明
To この電話番号への SMS メッセージのみを返します。
From この電話番号からの SMS メッセージのみを返します。
DateSent この日に送信された SMS メッセージのみを返却 ( GMT フォーマット) します。日付は YYYY-MM-DD 形式です。 例 : DateSent=2009-07-06 また、不等号も指定できます。たとえば、DateSent<=YYYY-MM-DD とすると、この日の午前 0 時以前に送信された SMS メッセージを返し、DateSent>=YYYY-MM-DD とすると、この日の午前 0 時以降に送信された SMS メッセージを返します。

メッセージのリスト全体を取得します。

Loading Code Samples...
言語
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
  • xml
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;

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 messages = MessageResource.Read();

        foreach (var message in messages)
        {
            Console.WriteLine(message.To);
        }
    }
}
<?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);

// Loop over the list of smss and echo a property for each one
foreach ($client->messages->read() as $sms) {
    echo $sms->to;
}
# 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)

# A list of sms objects with the properties described above
smss = client.sms.messages.list()
# 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/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Loop over smss and print out a property for each one
@client.account.messages.list.each do |message|
    puts message.to
end
// 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.sms.messages.list(function(err, data) {
    data.smsMessages.forEach(function(sms) {
        console.log(sms.to);
    });
});
// Download the Node helper library from twilio.com/docs/node/install
// These consts 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.messages
  .each((sms) => console.log(sms.to));
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// 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.Sms;
import com.twilio.sdk.resource.list.SmsList;

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);

    
    
    SmsList smss = client.getAccount().getSmsMessages();
    
    // Loop over smss and print out a property for each one.
    for (Sms sms : smss) {
      System.out.println(sms.getTo());
    }
    
  }
}
# 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)

# A list of sms objects with the properties described above
for sms in client.messages.list():
    print(sms.to)
// 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 smss = twilio.ListSmsMessages(null, null, null, null, null);
    
    foreach (var sms in smss.SMSMessages)
    {
      Console.WriteLine(sms.To);
    }
  }
}
<?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);

// Loop over the list of smss and echo a property for each one
foreach ($client->account->sms_messages as $sms) {
    echo $sms->to;
}
# 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


# Loop over smss and print out a property for each one
@client.account.sms.messages.list.each do |sms|
  puts sms.to
end
// 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.Message;

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<Message> smss = Message.reader().read();

    // Loop over smss and print out a property for each one.
    for (Message sms : smss) {
      System.out.println(sms.getTo());
    }
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
	"page": 0,
	"page_size": 50,
	"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json"
	"first_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json?Page=0&PageSize=50",
	"next_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json?Page=1&PageSize=50",
	"previous_page_uri": null,
	"sms_messages": [
		{
			"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
			"api_version": "2008-08-01",
			"body": "Hey Jenny why aren't you returning my calls?",
			"date_created": "Mon, 16 Aug 2010 03:45:01 +0000",
			"date_sent": "Mon, 16 Aug 2010 03:45:03 +0000",
			"date_updated": "Mon, 16 Aug 2010 03:45:03 +0000",
			"direction": "outbound-api",
			"from": "+14158141829",
			"price": "-0.02000",
			"sid": "SM800f449d0399ed014aae2bcc0cc2f2ec",
			"status": "sent",
			"to": "+14159978453",
			"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json"
		},
		...
	]
}
<TwilioResponse>
	<SMSMessages page="0" pagesize="50" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages" firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages?Page=0&amp;PageSize=50" previouspageuri="" nextpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages?Page=1&amp;PageSize=50">
		<SMSMessage>
			<Sid>SM800f449d0399ed014aae2bcc0cc2f2ec</Sid>
			<DateCreated>Mon, 16 Aug 2010 03:45:01 +0000</DateCreated>
			<DateUpdated>Mon, 16 Aug 2010 03:45:03 +0000</DateUpdated>
			<DateSent>Mon, 16 Aug 2010 03:45:03 +0000</DateSent>
			<AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
			<To>+14159978453</To>
			<From>+14158141829</From>
			<Body>Hey Jenny why aren't you returning my calls?</Body>
			<Status>sent</Status>
			<Direction>outbound-api</Direction>
			<Price>-0.02000</Price>
			<ApiVersion>2008-08-01</ApiVersion>
			<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec</Uri>
		</SMSMessage>
		...
	</SMSMessages>
</TwilioResponse>
すべての SMS のリストの取得

HTTP POST

新しい SMS メッセージを送信します。 詳細は、 SMS を送信する のセクションを参照してください。

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

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
レスポンス形式:
  • JSON
  • xml
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;

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 message = MessageResource.Fetch("SM800f449d0399ed014aae2bcc0cc2f2ec");

        Console.WriteLine(message.Body);
    }
}
<?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);

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$sms = $client
    ->messages("SM800f449d0399ed014aae2bcc0cc2f2ec")
    ->fetch();

echo $sms->body;
# 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)

sms = client.sms.messages.get("SM800f449d0399ed014aae2bcc0cc2f2ec")
print(sms.body)
# 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/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
message = @client.account.messages("SM800f449d0399ed014aae2bcc0cc2f2ec").fetch
puts message.body
// 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.sms.messages("SM800f449d0399ed014aae2bcc0cc2f2ec").get(function(err, sms) {
    console.log(sms.body);
});
// Download the Node helper library from twilio.com/docs/node/install
// These consts 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.messages('SM800f449d0399ed014aae2bcc0cc2f2ec')
  .fetch()
  .then((sms) => console.log(sms.body));
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// 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.Sms;

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);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Sms sms = client.getAccount().getSms("SM800f449d0399ed014aae2bcc0cc2f2ec");
    System.out.println(sms.getBody());
    
  }
}
# 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)

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
sms = client.messages("SM800f449d0399ed014aae2bcc0cc2f2ec") \
            .fetch()

print(sms.body)
// 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 sms = twilio.GetSmsMessage("SM800f449d0399ed014aae2bcc0cc2f2ec");
    
    Console.WriteLine(sms.Body);
  }
}
<?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);

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$sms = $client->account->sms_messages->get("SM800f449d0399ed014aae2bcc0cc2f2ec");
echo $sms->body;
# 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

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@sms = @client.account.sms.messages.get("SM800f449d0399ed014aae2bcc0cc2f2ec")
puts @sms.body
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;

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);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Message sms = Message.fetcher("SM800f449d0399ed014aae2bcc0cc2f2ec").fetch();

    System.out.println(sms.getBody());
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
	"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"api_version": "2008-08-01",
	"body": "Hey Jenny why aren't you returning my calls?",
	"date_created": "Mon, 16 Aug 2010 03:45:01 +0000",
	"date_sent": "Mon, 16 Aug 2010 03:45:03 +0000",
	"date_updated": "Mon, 16 Aug 2010 03:45:03 +0000",
	"direction": "outbound-api",
	"from": "+14158141829",
	"price": "-0.02000",
	"sid": "SM800f449d0399ed014aae2bcc0cc2f2ec",
	"status": "sent",
	"to": "+14159978453",
	"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json"
}
<TwilioResponse>
	<SMSMessage>
		<Sid>SM800f449d0399ed014aae2bcc0cc2f2ec</Sid>
		<DateCreated>Mon, 16 Aug 2010 03:45:01 +0000</DateCreated>
		<DateUpdated>Mon, 16 Aug 2010 03:45:03 +0000</DateUpdated>
		<DateSent>Mon, 16 Aug 2010 03:45:03 +0000</DateSent>
		<AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
		<To>+14159978453</To>
		<From>+14158141829</From>
		<Body>Hey Jenny why aren't you returning my calls?</Body>
		<Status>sent</Status>
		<Direction>outbound-api</Direction>
		<ApiVersion>2010-04-01</ApiVersion>
		<Price>-0.02000</Price>
		<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec</Uri>
	</SMSMessage>
</TwilioResponse>
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
  • xml
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;

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 messages = MessageResource.Read();

        foreach (var message in messages)
        {
            Console.WriteLine(message.To);
        }
    }
}
<?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);

// Loop over the list of smss and echo a property for each one
foreach ($client->messages->read() as $sms) {
    echo $sms->to;
}
# 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)

# A list of sms objects with the properties described above
smss = client.sms.messages.list()
# 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/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Loop over smss and print out a property for each one
@client.account.messages.list.each do |message|
    puts message.to
end
// 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.sms.messages.list(function(err, data) {
    data.smsMessages.forEach(function(sms) {
        console.log(sms.to);
    });
});
// Download the Node helper library from twilio.com/docs/node/install
// These consts 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.messages
  .each((sms) => console.log(sms.to));
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// 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.Sms;
import com.twilio.sdk.resource.list.SmsList;

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);

    
    
    SmsList smss = client.getAccount().getSmsMessages();
    
    // Loop over smss and print out a property for each one.
    for (Sms sms : smss) {
      System.out.println(sms.getTo());
    }
    
  }
}
# 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)

# A list of sms objects with the properties described above
for sms in client.messages.list():
    print(sms.to)
// 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 smss = twilio.ListSmsMessages(null, null, null, null, null);
    
    foreach (var sms in smss.SMSMessages)
    {
      Console.WriteLine(sms.To);
    }
  }
}
<?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);

// Loop over the list of smss and echo a property for each one
foreach ($client->account->sms_messages as $sms) {
    echo $sms->to;
}
# 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


# Loop over smss and print out a property for each one
@client.account.sms.messages.list.each do |sms|
  puts sms.to
end
// 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.Message;

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<Message> smss = Message.reader().read();

    // Loop over smss and print out a property for each one.
    for (Message sms : smss) {
      System.out.println(sms.getTo());
    }
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
	"page": 0,
	"page_size": 50,
	"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json"
	"first_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json?Page=0&PageSize=50",
	"next_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json?Page=1&PageSize=50",
	"previous_page_uri": null,
	"sms_messages": [
		{
			"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
			"api_version": "2008-08-01",
			"body": "Hey Jenny why aren't you returning my calls?",
			"date_created": "Mon, 16 Aug 2010 03:45:01 +0000",
			"date_sent": "Mon, 16 Aug 2010 03:45:03 +0000",
			"date_updated": "Mon, 16 Aug 2010 03:45:03 +0000",
			"direction": "outbound-api",
			"from": "+14158141829",
			"price": "-0.02000",
			"sid": "SM800f449d0399ed014aae2bcc0cc2f2ec",
			"status": "sent",
			"to": "+14159978453",
			"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json"
		},
		...
	]
}
<TwilioResponse>
	<SMSMessages page="0" pagesize="50" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages" firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages?Page=0&amp;PageSize=50" previouspageuri="" nextpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages?Page=1&amp;PageSize=50">
		<SMSMessage>
			<Sid>SM800f449d0399ed014aae2bcc0cc2f2ec</Sid>
			<DateCreated>Mon, 16 Aug 2010 03:45:01 +0000</DateCreated>
			<DateUpdated>Mon, 16 Aug 2010 03:45:03 +0000</DateUpdated>
			<DateSent>Mon, 16 Aug 2010 03:45:03 +0000</DateSent>
			<AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
			<To>+14159978453</To>
			<From>+14158141829</From>
			<Body>Hey Jenny why aren't you returning my calls?</Body>
			<Status>sent</Status>
			<Direction>outbound-api</Direction>
			<Price>-0.02000</Price>
			<ApiVersion>2008-08-01</ApiVersion>
			<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec</Uri>
		</SMSMessage>
		...
	</SMSMessages>
</TwilioResponse>