ツイートウェブURLもしくはツイートIDを使ってツイートを一つ指定し、それをoEmbed互換形式で取得します。 ツイッターのウィジット JavaScript がページに組み込まれている場合、取得したHTML文は自動的に埋め込み型ツイートとして認識されます。
The oEmbed endpoint allows customization of the final appearance of an Embedded Tweet by setting the corresponding properties in HTML markup to be interpreted by Twitter’s JavaScript bundled with the HTML response by default. 取得されるマークアップの形式は、新しい機能の追加やツイート表現の調整などによって今後変わる可能性もあります。
The Tweet fallback markup is meant to be cached on your servers for up to the suggested cache lifetime specified in the cache_age
.
oEmbed エンドポイントでは配布済みソフトのために api.twitter.com/1/statuses/oembed.{format}
で認証不要のリクエストをサポートしており、誰でも使用できます。
個々のサイトはアプリケーショントークンを使って oEmbed データを取得する必要があります。
GET statuses/
|
https://api.twitter.com/1.1/statuses/oembed.{format}
Resource URL
|
Resource Information
Response formats
JSON
XML
Requires authentication?
Yes
Rate limited?
Yes
Requests / 15-min window (user auth)
180
Requests / 15-min window (app auth)
180
|
リクエストする際には id
パラメータかurl
パラメータのどちらかは 必ず 設定してください。両方を設定する必要はありません。
取得するツイートのID。
サンプル値: 99530515043983360
ツイートが埋め込まれているURL。
サンプル値:
https://twitter.com/Interior/status/507185938620219395
に埋め込まれているツイートを指定するには、次のURLを使用します:https%3A%2F%2Ftwitter.com%Interior%2Fstatus%2F507185938620219395
ツイートを描写するピクセル単位での最大幅。この値は 220
から 550
までの範囲内でなければなりません。
指定した値が許容範囲を下回っていたり上回っていたりした場合は、それぞれサポートされている最小値、最大値に置き換えられます。; the reset width value will be reflected in the returned width
property.
Twitter は oEmbed でのmaxheight
パラメータをサポートしていないので注意してください。
ツイートは基本的に文字なので、画像や動画と違って高さを予測することができません。関連して、 oEmbed の応答ではheight
に関する値は返しません。
実装上ツイートの高さを維持する必要がある場合は、後述する hide_thread
パラメータと hide_media
パラメータを参照してください。
サンプル値: 325
true
や t
や 1
を設定した場合、 ツイート内のリンクは画像や動画やリンクプレビューへ変換されません。
サンプル値: true
true
や t
や 1
を設定すると、取得するツイートが別のツイートへのリプライだった場合、その会話スレッドでの前後のツイートは表示されません。
サンプル値: true
true
や t
や 1
を設定した場合、widgets.js
を読み込むための <script>
レスポンシブルは取得されません。Embedded Tweetsを含む全てのTwitter ウィジットを使用するには、あなたのウェブページ上でwidgets.js
への参照を宣言する必要があります。
サンプル値: true
埋め込み型ツイートをページ上で左寄り、右寄り、中央のいずれに設置するかを指定します。
left
, right
, center
, none
うちいずれかを使用できます.既定では none
になっており、ツイートにアライメントスタイルは設定しません。
サンプル値: center
あなたのコンテンツに関連するTwitter ユーザー名をコンマ区切りでまとめた一覧。 ツイートを見た人がこの埋め込みツイートにリプライやお気に入り登録やリツイートをした場合、この一覧はTweet action intentsへ送られます。
サンプル値:
twitterapi,twitter
video
を設定すると、ツイート用の埋め込みTwitter 動画 を取得します。
サンプル値: video
video
タイプを設定した場合にのみ適用されるパラメータ。1
か true
を設定すると、ツイートを見た人がTwitter の鳥のアイコンとクリックした時に、
ツイートをオーバレイ表示せずにTweet URLへ直接リンクします。
サンプル値: 1
ParametersEither the
id
required
The ID of the desired Tweet. Example Values:
url
required
The URL of the Tweet to be embedded. Example Values: To embed the Tweet at
maxwidth
The maximum width of a rendered Tweet in whole pixels. This value must be between Note that Twitter does not support the oEmbed Example Values:
hide_media
When set to Example Values:
hide_thread
When set to Example Values:
omit_script
When set to Example Values:
align
Specifies whether the embedded Tweet should be floated left, right, or center in the page relative to the parent element. Valid values are Example Values:
related
A comma-separated list of Twitter usernames related to your content. This value will be forwarded to Tweet action intents if a viewer chooses to reply, favorite, or retweet the embedded Tweet. Example Values:
lang
Request returned HTML and a rendered Tweet in the specified Twitter language supported by embedded Tweets. Example Values:
widget_type
Set to Example Value:
hide_tweet
Applies to Example Value: |
ログイン して登録アプリケーションの一覧を参照してください。
OAuth Signature GeneratorSign in to see a list of your registered applications. |
GET
https://api.twitter.com/1.1/statuses/oembed.json?id=507185938620219395
Example Request
GET
https://api.twitter.com/1.1/statuses/oembed.json?id=507185938620219395
応答結果の例
{
"cache_age": "3153600000",
"url": "https://twitter.com/Interior/status/507185938620219395",
"provider_url": "https://twitter.com",
"provider_name": "Twitter",
"author_name": "US Dept of Interior",
"version": "1.0",
"author_url": "https://twitter.com/Interior",
"type": "rich",
"html": "<blockquote class="twitter-tweet"><p>Happy 50th anniversary to the Wilderness Act! Here's a great wilderness photo from <a href="https://twitter.com/YosemiteNPS">@YosemiteNPS</a>. <a href="https://twitter.com/hashtag/Wilderness50?src=hash">#Wilderness50</a> <a href="http://t.co/HMhbyTg18X">pic.twitter.com/HMhbyTg18X</a></p>— US Dept of Interior (@Interior) <a href="https://twitter.com/Interior/status/507185938620219395">September 3, 2014</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>",
"height": null,
"width": 550
}
Example Result
{
"cache_age": "3153600000",
"url": "https://twitter.com/Interior/status/507185938620219395",
"provider_url": "https://twitter.com",
"provider_name": "Twitter",
"author_name": "US Dept of Interior",
"version": "1.0",
"author_url": "https://twitter.com/Interior",
"type": "rich",
"html": "<blockquote class="twitter-tweet"><p>Happy 50th anniversary to the Wilderness Act! Here's a great wilderness photo from <a href="https://twitter.com/YosemiteNPS">@YosemiteNPS</a>. <a href="https://twitter.com/hashtag/Wilderness50?src=hash">#Wilderness50</a> <a href="http://t.co/HMhbyTg18X">pic.twitter.com/HMhbyTg18X</a></p>— US Dept of Interior (@Interior) <a href="https://twitter.com/Interior/status/507185938620219395">September 3, 2014</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>",
"height": null,
"width": 550
}