REST API: メディア

Mediaインスタンスはメッセージに関連するイメージを示します。メディアはインバウンド、アウトバンド両方生成されます。Twilioを通じてイメージを送受信した時、Twilioはメディアインスタンスを作り、コンテンツを保存します。

TwilioはそのインスタンスでHTTP DELETE を発行するまでメディアを保持し続けます。Twilioは最初の5GBまでのメッセージを無料で保管します。より詳しい情報は料金のページをご覧ください。

10個のメディアファイルを含めることができ、総サイズは5MBです。キャリアの仕様の送信成功事例を元に、必要ならファイルをリサイズします。5MBを超えるメティアファイルは拒否されます。

そのメディアリストリソースはメセージに関連するメディアを表します。

メディアインスタンスリソース

このリソースはメッセージに関連する個別のメディアを表します。

リソース URI

/2010-04-01/Accounts/{AccountSid}/Messages/{MessageSid}/Media/{MediaSid}
これらのURLは外部のアプリケーションにとって非常に便利なため、HTTPベーシック認証などを必要としないパブリックな状態で提供されます。Twilio APIのクレデンシャル情報を外部に晒すこと無く簡単にウェブアプリケーションにURLを埋め込むことができます。そのURLは長く、推測が難しいです。そのためURLを配布するまではプライベートな状態になります。

リソースのプロパティ

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

プロパティ 説明
Sid このリソースを一意に識別する 34 文字の文字列です。
DateCreated このリソースが生成された日付です。 RFC 2822 フォーマットを使用します。
DateUpdated このリソースが最後に更新された日付です。 RFC 2822 フォーマットを使用します。
AccountSid メディアに関連するアカウントのユニーク ID です。
ParentSid メディアを生成する一意のID
ContentType デフォルトのメディアのMIMEタイプ例 : image/jpeg,image/png,image/gif
Uri URIリソース、右に関連する https://api.twilio.com

HTTP GET

いくつかの表現の中から 1 つを返します。

デフォルト: content-type

拡張しない場合、メディアは生成時にそのMIMEタイプを返されます。例 :

GET /2010-04-01/Accounts/AC.../Message/MM.../Media/ME557ce644e5ab84fa21cc21112e22c485
デフォルト以外: XML

URI に「.xml」をつけると、通常の XML 表現を返します。 たとえば、次のようになります。

GET /2010-04-01/Accounts/AC.../Message/MM.../Media/ME557ce644e5ab84fa21cc21112e22c485.xml
<TwilioResponse>
 <Media>
   <Sid>ME557ce644e5ab84fa21cc21112e22c485</Sid>
   <AccountSid>ACda6f1e11047ebd6fe7a55f120be3a900</AccountSid>
   <ParentSid>MM8dfedb55c129dd4d6bd1f59af9d11080</ParentSid>
   <Content-Type>image/jpeg</Content-Type>
   <DateCreated>Fri, 17 Jul 2009 01:52:49 +0000</DateCreated>
   <DateUpdated>Fri, 17 Jul 2009 01:52:49 +0000</DateUpdated>
   <Uri>/2010-04-01/Accounts/ACda6f1e11047ebd6fe7a55f120be3a900/Message/MM8dfedb55c129dd4d6bd1f59af9d11080/Media/ME557ce644e5ab84fa21cc21112e22c485.xml</Uri>
 </Media>
</TwilioResponse>
代替手段 : JSON

URI に「.JSON」をつけると、JSON 表現を返します。 たとえば、次のようになります。

GET /2010-04-01/Accounts/AC.../Message/MM.../Media/ME557ce644e5ab84fa21cc21112e22c485.json
{
    "sid": "ME557ce644e5ab84fa21cc21112e22c485",
    "account_sid": "ACda6f1e11047ebd6fe7a55f120be3a900",
    "parent_sid": "MM8ff928b2451c0db925bd2d581f0fba79",
    "content-type": "image/jpeg",
    "date_created": "Fri, 26 Apr 2013 05:41:35 +0000",
    "date_updated": "Fri, 26 Apr 2013 05:41:35 +0000",
    "uri": "/2010-04-01/Accounts/ACda6f1e11047ebd6fe7a55f120be3a900/Message/MM8dfedb55c129dd4d6bd1f59af9d11080/Media/ME557ce644e5ab84fa21cc21112e22c485.json"
}

HTTP POST

サポートしません。

HTTP PUT

サポートしません。

HTTP DELETE

メディアをアカウントから削除。一度メディアを削除するとメディアの保管に料金はかかりません。

削除に成功すると、ボディーのない HTTP 204 (No Content) レスポンスを返します。

Delete a Media
  • C#
  • curl
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
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
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account.Message;

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 messageSid = "MM800f449d0399ed014aae2bcc0cc2f2ec";
        const string mediaSid = "ME557ce644e5ab84fa21cc21112e22c485";
        MediaResource.Delete(messageSid,
                             mediaSid);
    }
}
<?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);

$client->messages("MM800f449d0399ed014aae2bcc0cc2f2ec")
    ->media("ME557ce644e5ab84fa21cc21112e22c485")
    ->delete();
# 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)

client.messages.get("MM800f449d0399ed014aae2bcc0cc2f2ec").media_list.delete("ME557ce644e5ab84fa21cc21112e22c485")
# 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)

@media = @client.account.messages('MM800f449d0399ed014aae2bcc0cc2f2ec')
                .media('ME557ce644e5ab84fa21cc21112e22c485').fetch

@media.delete
$ curl -XDELETE https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME557ce644e5ab84fa21cc21112e22c485.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -XDELETE https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME557ce644e5ab84fa21cc21112e22c485 \
    -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.Media;

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
    Media media = client.getAccount().getMessage("MM800f449d0399ed014aae2bcc0cc2f2ec").getMedia("ME557ce644e5ab84fa21cc21112e22c485");

    media.delete(); 
  }
}
# 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)

client.messages("MM800f449d0399ed014aae2bcc0cc2f2ec") \
      .media("ME557ce644e5ab84fa21cc21112e22c485") \
      .delete()
// 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);

const mediaSid = 'ME557ce644e5ab84fa21cc21112e22c485';

client.messages('MM800f449d0399ed014aae2bcc0cc2f2ec').media(mediaSid)
  .remove()
  .then(() => {
    console.log(`Sid ${mediaSid} deleted successfully.`);
  })
  .catch((err) => console.log(err));
// 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);

    twilio.DeleteMedia("MM800f449d0399ed014aae2bcc0cc2f2ec", "ME557ce644e5ab84fa21cc21112e22c485");
  }
}
<?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);

$client->account->messages->get("MM800f449d0399ed014aae2bcc0cc2f2ec")->media->delete("ME557ce644e5ab84fa21cc21112e22c485");
# 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

@media = @client.messages.get("MM800f449d0399ed014aae2bcc0cc2f2ec").media.get("ME557ce644e5ab84fa21cc21112e22c485")
@media.delete
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.message.Media;

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
    Media.deleter("MM800f449d0399ed014aae2bcc0cc2f2ec", "ME557ce644e5ab84fa21cc21112e22c485")
        .delete();
  }
}
// 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.messages("MM800f449d0399ed014aae2bcc0cc2f2ec").media("ME557ce644e5ab84fa21cc21112e22c485").delete(function(err, data) {
    if (err) {
        console.log(err.status);
        throw err.message;
    } else {
        console.log("Sid ME557ce644e5ab84fa21cc21112e22c485 deleted successfully.");
    }
});
Delete a Media

メディアリストリソース

リソース URI

/2010-04-01/Accounts/{AccountSid}/Messages/{MessageSid}/Media

HTTP GET

メッセージに関連するメディアのリストを返します。このリストはページ情報を含みます。

リスト フィルター

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

パラメーター 説明
DateCreated 与えられた日付に生成されたメディアのみを表示。YYYY-MM-DDの形式で入力して下さい。DateCreated<=YYYY-MM-DDDateCreated>=YYYY-MM-DDのように不等号を使って表現する事もできます。前者ではその日付以前、後者ではその日付後を検索できます。

メッセージに関連するメディアを返します。

Get a Media
  • C#
  • curl
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
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
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account.Message;

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 messageSid = "MM800f449d0399ed014aae2bcc0cc2f2ec";
        var medias = MediaResource.Read(messageSid);

        foreach (var media in medias)
        {
            Console.WriteLine(media.ContentType);
        }
    }
}
<?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);

$allMedia = $client
    ->messages("MM800f449d0399ed014aae2bcc0cc2f2ec")
    ->media
    ->read();

// Loop over the list of media and echo a property for each one
foreach ($allMedia as $media) {
    echo $media->contentType;
}
# 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 media objects with the properties described above
medias = client.media('MM800f449d0399ed014aae2bcc0cc2f2ec').list()
# 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)

@client.account.messages('MM800f449d0399ed014aae2bcc0cc2f2ec')
       .media.list.each do |media|
         puts media.content_type
       end
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media \
    -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.Media;
import com.twilio.sdk.resource.list.MediaList;

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);
 
    MediaList medias = client.getAccount().getMessage("MM800f449d0399ed014aae2bcc0cc2f2ec").getMedia();
    
    // Loop over medias and print out a property for each one.
    for (Media media : medias) {
      System.out.println(media.getContentType());
    }
    
  }
}
# 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 media objects with the properties described above
medias = client.messages('MM800f449d0399ed014aae2bcc0cc2f2ec') \
               .media \
               .list()

for media in medias:
    print(media.content_type)
// 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.messages('MM800f449d0399ed014aae2bcc0cc2f2ec')
  .media.each((media) => console.log(media.contentType));
// 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 MediaListRequest();
    
    var medias = twilio.ListMessageMedia("MM800f449d0399ed014aae2bcc0cc2f2ec", options);
    
    foreach (var media in medias.Medias)
    {
      Console.WriteLine(media.ContentType);
    }
  }
}
<?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 medias and echo a property for each one
foreach ($client->account->messages->get('MM800f449d0399ed014aae2bcc0cc2f2ec')->media as $media) {
    echo $media->content_type;
}
# 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 medias and print out a property for each one
@client.account.messages.get('MM800f449d0399ed014aae2bcc0cc2f2ec').media.list.each do |media|
  puts media.content_type
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.Media;

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<Media> allMedia = Media.reader("MM800f449d0399ed014aae2bcc0cc2f2ec").read();

    // Loop over media and print out a property for each one.
    for (Media media : allMedia) {
      System.out.println(media.getContentType());
    }
  }
}
// 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.messages('MM800f449d0399ed014aae2bcc0cc2f2ec').media.list(function(err, data) {
    data.mediaList.forEach(function(media) {
        console.log(media.contentType);
    });
});
出力を表示
  • JSON
  • XML
{ "first_page_uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media.json?PageSize=50&Page=0",
    "media_list":[
       {
          "sid":"ME85ebf7e12cb821f84b319340424dcb02",
          "account_sid":"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
          "parent_sid":"MM800f449d0399ed014aae2bcc0cc2f2ec",
          "content_type":"image/png",
          "date_created":"Wed, 25 Sep 2013 22:47:18 +0000",
          "date_updated":"Wed, 25 Sep 2013 22:47:19 +0000",
          "uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME85ebf7e12cb821f84b319340424dcb02.json"
       },
       {
          "sid":"ME8d8f717e2d6e5383055b3cd150ac5f54",
          "account_sid":"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
          "parent_sid":"MM800f449d0399ed014aae2bcc0cc2f2ec",
          "content_type":"image/png",
          "date_created":"Wed, 25 Sep 2013 22:47:18 +0000",
          "date_updated":"Wed, 25 Sep 2013 22:47:19 +0000",
          "uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME8d8f717e2d6e5383055b3cd150ac5f54.json"
       }
    ],
    "previous_page_uri":null,
    "uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media.json?PageSize=50&Page=0",
    "page_size":50,
    "next_page_uri":null,
    "page":0
 }
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
  <MediaList firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media?PageSize=50&amp;Page=0" nextpageuri="" page="0" pagesize="50" previouspageuri="" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media?PageSize=50&amp;Page=0">
    <Media>
      <Sid>ME85ebf7e12cb821f84b319340424dcb02</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <ParentSid>MM800f449d0399ed014aae2bcc0cc2f2ec</ParentSid>
      <ContentType>image/png</ContentType>
      <DateCreated>Wed, 25 Sep 2013 22:47:18 +0000</DateCreated>
      <DateUpdated>Wed, 25 Sep 2013 22:47:19 +0000</DateUpdated>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME85ebf7e12cb821f84b319340424dcb02</Uri>
    </Media>
    <Media>
      <Sid>ME8d8f717e2d6e5383055b3cd150ac5f54</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <ParentSid>MM800f449d0399ed014aae2bcc0cc2f2ec</ParentSid>
      <ContentType>image/png</ContentType>
      <DateCreated>Wed, 25 Sep 2013 22:47:18 +0000</DateCreated>
      <DateUpdated>Wed, 25 Sep 2013 22:47:19 +0000</DateUpdated>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME8d8f717e2d6e5383055b3cd150ac5f54</Uri>
    </Media>
  </MediaList>
</TwilioResponse>
Get a Media

HTTP POST

サポートしません。

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

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
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account.Message;

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 messageSid = "MM800f449d0399ed014aae2bcc0cc2f2ec";
        const string mediaSid = "ME557ce644e5ab84fa21cc21112e22c485";
        MediaResource.Delete(messageSid,
                             mediaSid);
    }
}
<?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);

$client->messages("MM800f449d0399ed014aae2bcc0cc2f2ec")
    ->media("ME557ce644e5ab84fa21cc21112e22c485")
    ->delete();
# 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)

client.messages.get("MM800f449d0399ed014aae2bcc0cc2f2ec").media_list.delete("ME557ce644e5ab84fa21cc21112e22c485")
# 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)

@media = @client.account.messages('MM800f449d0399ed014aae2bcc0cc2f2ec')
                .media('ME557ce644e5ab84fa21cc21112e22c485').fetch

@media.delete
$ curl -XDELETE https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME557ce644e5ab84fa21cc21112e22c485.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -XDELETE https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME557ce644e5ab84fa21cc21112e22c485 \
    -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.Media;

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
    Media media = client.getAccount().getMessage("MM800f449d0399ed014aae2bcc0cc2f2ec").getMedia("ME557ce644e5ab84fa21cc21112e22c485");

    media.delete(); 
  }
}
# 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)

client.messages("MM800f449d0399ed014aae2bcc0cc2f2ec") \
      .media("ME557ce644e5ab84fa21cc21112e22c485") \
      .delete()
// 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);

const mediaSid = 'ME557ce644e5ab84fa21cc21112e22c485';

client.messages('MM800f449d0399ed014aae2bcc0cc2f2ec').media(mediaSid)
  .remove()
  .then(() => {
    console.log(`Sid ${mediaSid} deleted successfully.`);
  })
  .catch((err) => console.log(err));
// 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);

    twilio.DeleteMedia("MM800f449d0399ed014aae2bcc0cc2f2ec", "ME557ce644e5ab84fa21cc21112e22c485");
  }
}
<?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);

$client->account->messages->get("MM800f449d0399ed014aae2bcc0cc2f2ec")->media->delete("ME557ce644e5ab84fa21cc21112e22c485");
# 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

@media = @client.messages.get("MM800f449d0399ed014aae2bcc0cc2f2ec").media.get("ME557ce644e5ab84fa21cc21112e22c485")
@media.delete
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.message.Media;

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
    Media.deleter("MM800f449d0399ed014aae2bcc0cc2f2ec", "ME557ce644e5ab84fa21cc21112e22c485")
        .delete();
  }
}
// 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.messages("MM800f449d0399ed014aae2bcc0cc2f2ec").media("ME557ce644e5ab84fa21cc21112e22c485").delete(function(err, data) {
    if (err) {
        console.log(err.status);
        throw err.message;
    } else {
        console.log("Sid ME557ce644e5ab84fa21cc21112e22c485 deleted successfully.");
    }
});
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.Message;

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 messageSid = "MM800f449d0399ed014aae2bcc0cc2f2ec";
        var medias = MediaResource.Read(messageSid);

        foreach (var media in medias)
        {
            Console.WriteLine(media.ContentType);
        }
    }
}
<?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);

$allMedia = $client
    ->messages("MM800f449d0399ed014aae2bcc0cc2f2ec")
    ->media
    ->read();

// Loop over the list of media and echo a property for each one
foreach ($allMedia as $media) {
    echo $media->contentType;
}
# 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 media objects with the properties described above
medias = client.media('MM800f449d0399ed014aae2bcc0cc2f2ec').list()
# 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)

@client.account.messages('MM800f449d0399ed014aae2bcc0cc2f2ec')
       .media.list.each do |media|
         puts media.content_type
       end
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media \
    -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.Media;
import com.twilio.sdk.resource.list.MediaList;

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);
 
    MediaList medias = client.getAccount().getMessage("MM800f449d0399ed014aae2bcc0cc2f2ec").getMedia();
    
    // Loop over medias and print out a property for each one.
    for (Media media : medias) {
      System.out.println(media.getContentType());
    }
    
  }
}
# 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 media objects with the properties described above
medias = client.messages('MM800f449d0399ed014aae2bcc0cc2f2ec') \
               .media \
               .list()

for media in medias:
    print(media.content_type)
// 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.messages('MM800f449d0399ed014aae2bcc0cc2f2ec')
  .media.each((media) => console.log(media.contentType));
// 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 MediaListRequest();
    
    var medias = twilio.ListMessageMedia("MM800f449d0399ed014aae2bcc0cc2f2ec", options);
    
    foreach (var media in medias.Medias)
    {
      Console.WriteLine(media.ContentType);
    }
  }
}
<?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 medias and echo a property for each one
foreach ($client->account->messages->get('MM800f449d0399ed014aae2bcc0cc2f2ec')->media as $media) {
    echo $media->content_type;
}
# 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 medias and print out a property for each one
@client.account.messages.get('MM800f449d0399ed014aae2bcc0cc2f2ec').media.list.each do |media|
  puts media.content_type
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.Media;

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<Media> allMedia = Media.reader("MM800f449d0399ed014aae2bcc0cc2f2ec").read();

    // Loop over media and print out a property for each one.
    for (Media media : allMedia) {
      System.out.println(media.getContentType());
    }
  }
}
// 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.messages('MM800f449d0399ed014aae2bcc0cc2f2ec').media.list(function(err, data) {
    data.mediaList.forEach(function(media) {
        console.log(media.contentType);
    });
});
{ "first_page_uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media.json?PageSize=50&Page=0",
    "media_list":[
       {
          "sid":"ME85ebf7e12cb821f84b319340424dcb02",
          "account_sid":"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
          "parent_sid":"MM800f449d0399ed014aae2bcc0cc2f2ec",
          "content_type":"image/png",
          "date_created":"Wed, 25 Sep 2013 22:47:18 +0000",
          "date_updated":"Wed, 25 Sep 2013 22:47:19 +0000",
          "uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME85ebf7e12cb821f84b319340424dcb02.json"
       },
       {
          "sid":"ME8d8f717e2d6e5383055b3cd150ac5f54",
          "account_sid":"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
          "parent_sid":"MM800f449d0399ed014aae2bcc0cc2f2ec",
          "content_type":"image/png",
          "date_created":"Wed, 25 Sep 2013 22:47:18 +0000",
          "date_updated":"Wed, 25 Sep 2013 22:47:19 +0000",
          "uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME8d8f717e2d6e5383055b3cd150ac5f54.json"
       }
    ],
    "previous_page_uri":null,
    "uri":"/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media.json?PageSize=50&Page=0",
    "page_size":50,
    "next_page_uri":null,
    "page":0
 }
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
  <MediaList firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media?PageSize=50&amp;Page=0" nextpageuri="" page="0" pagesize="50" previouspageuri="" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media?PageSize=50&amp;Page=0">
    <Media>
      <Sid>ME85ebf7e12cb821f84b319340424dcb02</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <ParentSid>MM800f449d0399ed014aae2bcc0cc2f2ec</ParentSid>
      <ContentType>image/png</ContentType>
      <DateCreated>Wed, 25 Sep 2013 22:47:18 +0000</DateCreated>
      <DateUpdated>Wed, 25 Sep 2013 22:47:19 +0000</DateUpdated>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME85ebf7e12cb821f84b319340424dcb02</Uri>
    </Media>
    <Media>
      <Sid>ME8d8f717e2d6e5383055b3cd150ac5f54</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <ParentSid>MM800f449d0399ed014aae2bcc0cc2f2ec</ParentSid>
      <ContentType>image/png</ContentType>
      <DateCreated>Wed, 25 Sep 2013 22:47:18 +0000</DateCreated>
      <DateUpdated>Wed, 25 Sep 2013 22:47:19 +0000</DateUpdated>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MM800f449d0399ed014aae2bcc0cc2f2ec/Media/ME8d8f717e2d6e5383055b3cd150ac5f54</Uri>
    </Media>
  </MediaList>
</TwilioResponse>