-
Notifications
You must be signed in to change notification settings - Fork 4
/
471.txt
292 lines (229 loc) · 10.9 KB
/
471.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
[32]
[DFN[oEmbed]]
は、
[[Webページ]]の情報の埋め込みに必要な情報の取得に関する[[プロトコル]]です。
[[HTTP]] と [[HTML]] の上位に構築された[[プロトコル]]となっています。
* 仕様書
[REFS[
- [1] [CITE[oEmbed]]
([TIME[2010-11-11 04:14:55 +09:00]] 版)
<http://www.oembed.com/>
]REFS]
* プロトコル
[12]
[FIG(short list)[
- [CODE(HTML)@en[[[rel=alternate]]]]
]FIG]
** [CODE[rel=alternate]]
[19]
[[oEmbed]] は
[CODE[<[[link]] [[rel=alaternate]]>]]
による
[[discovery]]
を定めています。
[SRC[>>1]]
[20] この [[URL]] について、
[[仕様書]]は
「The URLs contained within the [CODE[href]] attribute should be the full oEmbed endpoint plus URL and any needed format parameter. No other request parameters should be included in this URL.」
と規定しています [SRC[>>1]]。
[[oEmbed]] は[[エンドポイント]]に [[URL]] と format (JSON or XML)
の[[引数]]を与えることを想定していて、それを含めることを求めているのですが、
「full」
という言葉は[[相対URL]]でなく[[絶対URL]]でなければならないと要求していると解釈できないこともありません。
[21] [[仕様書]]の例は[[絶対URL]]
になっています。
[22] 同時代の他の [[discovery]] 系の仕様は[[絶対URL]]を想定する仕様書になっていたり、
実装になっていたりしました。その時代背景から、[[絶対URL]]
が暗黙に仮定されていたと主張できないこともありません。
[23]
[[oEmbed]]
[[仕様書]]は現代の視点では
[WEAK[(実は当時でも言う人に言わせれば...)]]
曖昧すぎて技術仕様書の体をなしていないと言わざるを得ません。
行間を読まずに厳密に解釈して理解することは不可能です。
[24]
敢えて厳密に解釈を試みるなら、
[CITE[HTML Standard]]
も
[[oEmbed]]
仕様書も、
[[相対URL]]
を禁止する特別の規定を欠いていますから、
[[相対URL]]も[[絶対URL]]も含む任意の
[[URL]]
が認められると解さざるを得ません。
[18]
[CODE[link]] [[要素]]の [CODE[href][<link href>]]
[[属性]]の値が[[相対URL]]
であったとしても、
[CITE[Iframely]]
は正しく解釈します。
[CITE[はてなブログ]]
は解釈に失敗するのか、無視します。
[TIME[2020-05-13T08:51:17.200Z]]
[25]
また [CODE[href]] に指定できる [[URL scheme]]
に制限があるのかどうかも、よくわかりません。
一般的な実装は [CODE[http:]] や [CODE[https:]]
に対応しているようです。それ以外の、
例えば
[CODE[data:]]
を使ったときの挙動は定かではありません。
[[oEmbed]] の仕様書には [[URL]] を [[HTTP]]
か [[HTTPS]] に制限する趣旨の記述が何箇所かみえますが、
それが
[CODE[href]] 属性値に適用されるのかどうか明確にできません。
[29]
[CITE[Iframely]]
も
[CITE[はてなブログ]]
も
[CODE[data:]]
[[URL]]
には対応していないようで、
[[oEmbed]]
がないものと扱います。
[TIME[2020-05-13T09:17:33.400Z]]
* MIME型
[31]
[[Perlモジュール]]
[CODE[Web::oEmbed]]
は、
[[応答]]の
[CODE[Content-Type:]]
に
[CODE[json]]
が入るか
[CODE[xml]]
が入るかで分岐し、
それ以外は捨てているようです。
どちらかに適切に設定する必要があります。
また [CODE[link]]
[[要素]]の
[[MIME型]]は処理に影響しないようです。
* データ
[26]
[[Perlモジュール]]
[CODE[Web::oEmbed]]
は、いくつかの条件がありますが、
最終的に
[CODE[html]]
の値があれば、これを使います。
[27]
[CITE[はてなブログ]]は、
[CODE[html]]
の値さえあればこれを埋め込み用 [[HTML]] として使うようです。
[TIME[2020-05-13T09:13:04.00Z]]
* 評価
[9] [[oEmbed]] は専用の [[API]] を用意して情報を提供する形のため、
サーバー側もクライアント側も (事前に [[oEmbed]] に対応していることとその
[[API]] の [[URL]] を把握している場合を除き) 余分な一手間をかける必要があります。
[[YouTube]] や [[SlideShare]] のように埋め込みのための [[HTML]] 片を取得することに特に意義がある場合はともかく、
通常の[[HTML]]の[[要素]] ([CODE(HTMLe)@en[[[title]]]] など) や
[[SNS用のWebページデータ]]で得られる程度の情報しか提供できないのなら、
敢えて [[oEmbed]] を使う意味はなさそうです。
[10] つまり[[画像]]や[[動画]]、[[対話的内容]]などを提供するサービスで、
(単なる[[リンク]]ではなく) その内容自体を埋め込むことが有用なら、 [[oEmbed]]
は有益となります。逆に、[[文章]]の一部を要約として提供したり、
特徴的な一場面を[[サムネイル画像]]として提供したりする程度なら、
他の方法で十分ですし、[[利用者]]の体験はかえって悪くなるかもしれません。
* 実装
[11] [[oEmbed]] を提供しているサービスの一部は、 >>1 の一覧に掲載されています。
掲載されていなくても実装しているサービスがいくつかあるようです。
[[YouTube]] や [[Flickr]] をはじめ、いろいろなサービスが実装しています。
しかしどんなサービスでも大方対応しているというほど広く普及しているわけでもないようです。
[TIME[2015-11-02T03:33:10.400Z]]
[28]
[CITE[はてなブログ]]
は、
[[URL]]
を貼り付けると、
(デフォルトの挙動では)
その貼り付け形式を選ぶダイアログを表示します。
そのうち「埋め込み」形式は、
その場で当該 [[URL]]
を取得し、
[CODE[<[[link]] [[rel=alternate]]>]]
で
[[discovery]]
を試み、
[CODE[html]]
の値があればそれを採用するようです。
[TIME[2020-05-13T09:14:17.00Z]]
[30]
[CITE[はてなブログ]]
では提供された
[CODE[html]]
がそのまま文書に挿入され、編集可能なテキストの一部に溶け込みます。
[[WYSIWYG]] エディターによる [[HTML]]
としての改変を受けます。
(例えば [CODE[strong]] が [CODE[b]] に置き換えられたりします。)
[TIME[2020-05-13T09:32:10.800Z]]
* メモ
[2] [CITE@ja[はてなブログoEmbed APIを公開しました。ブログカードの情報をAPIで取得できます(開発者向け) - はてなブログ開発ブログ]]
( ([TIME[2014-09-03 07:18:45 +09:00]] 版))
<http://staff.hatenablog.com/entry/2014/09/03/153938>
[3] [CITE[はてなブログoEmbed API - Hatena Developer Center]]
( ([TIME[2014-09-03 07:26:52 +09:00]] 版))
<http://developer.hatena.ne.jp/ja/documents/blog/apis/oembed>
[4] [CITE@en[iamcal/oembed]]
( ([TIME[2014-09-03 07:27:30 +09:00]] 版))
<https://github.com/iamcal/oembed>
[5] [CITE[はてなブックマークoEmbed API - Hatena Developer Center]]
( ([TIME[2014-10-23 14:23:11 +09:00]] 版))
<http://developer.hatena.ne.jp/ja/documents/bookmark/apis/oembed>
[6] [CITE@en[OEmbed Documentation]]
([TIME[2015-03-06 08:59:45 +09:00]] 版)
<http://www.slideshare.net/developers/oembed>
[7] [CITE@en[iamcal/oembed]]
([TIME[2015-10-22 22:51:01 +09:00]] 版)
<https://github.com/iamcal/oembed>
[8] [CITE@ja[「ブログカード」をOGPなどに対応しました。さまざまなWebページをコンパクトに整形して掲載できます - はてなブログ開発ブログ]]
([TIME[2015-10-27 23:06:01 +09:00]] 版)
<http://staff.hatenablog.com/entry/2014/09/05/143600>
[13] [CITE[はてなブックマークoEmbed API - Hatena Developer Center]]
([TIME[2016-03-21 10:45:31 +09:00]] 版)
<http://developer.hatena.ne.jp/ja/documents/bookmark/apis/oembed>
[FIG(quote)[
[FIGCAPTION[
[14] [CITE@ja[税理士なら港区の税理士法人インテグリティ]]
( ([TIME[2016-06-14 12:01:33 +09:00]]))
<http://www.integrity.or.jp/>
]FIGCAPTION]
>
> <link rel="alternate" type="application/json+oembed" href="http://www.integrity.or.jp/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fwww.integrity.or.jp%2F" />
> <link rel="alternate" type="text/xml+oembed" href="http://www.integrity.or.jp/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fwww.integrity.or.jp%2F&format=xml" />
]FIG]
[FIG(quote)[
[FIGCAPTION[
[15] [CITE@en[Slack Robots | Slack]]
( ([[Slack]]著, [TIME[2017-05-24 15:10:26 +09:00]]))
<https://api.slack.com/robots>
]FIGCAPTION]
> Specifically, we are looking for oEmbed and Twitter Card / Open Graph tags.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[16] [CITE@ja[コメント一覧ページのデザインリニューアルおよびページ内の一部機能の廃止・整理を行います - はてなブックマーク開発ブログ]]
([TIME[2017-08-08 20:57:01 +09:00]])
<http://bookmark.hatenastaff.com/entry/2017/08/08/150000>
]FIGCAPTION]
> 下記の機能については、8月21日(月)のリニューアルに伴いいったん廃止いたしますが、今後の機能開発を経てあらためて実装する予定です。
> YouTube、ニコニコ動画、SlideShare、Twitter、Facebook、Speaker Deckなどのサービスについて、コメント一覧ページ内で埋め込み機能(oEmbed)を使ってコンテンツを展開する機能
]FIG]
[17] [CITE@en[Iframely URL Debugger - Open Graph, Twitter Cards, oEmbed]], [TIME[2020-05-13 17:46:36 +09:00]] <http://debug.iframely.com/>
[33] [CITE[Announcing OEmbed - An Open Standard for Embedded Content - Leah Culver's Blog]], [TIME[2020-10-01T10:02:52.000Z]] <https://blog.leahculver.com/2008/05/announcing-oembed-an-open-standard-for-embedded-content.html>
[34] [CITE@ja[oEmbed - Instagramプラットフォーム]], [TIME[2020-10-27T01:34:53.000Z]] <https://developers.facebook.com/docs/instagram/oembed>
[35] [[Instagram]] は従来の誰でも利用できた標準的な [[oEmbed]]
を[[非推奨]]化 (いずれは廃止するのだろう)。
新たに登録と [[Facebook]] 社の許諾によって取得した[[アクセストークン]]が必要な[[エンドポイント]]を設けて
[[oEmbed]] と呼んでいる。
本来の [[oEmbed]] とはデータ構造が似ているだけで、
もはや標準の [[oEmbed]] ではない。
(標準の [[oEmbed]] は相手方サービスがどこであるか知らなくても利用できるというメリットがあったが、
この新しい[[エンドポイント]]は相手方が [[Facebook]]
だと知らないことには使えない。
これを
[[oEmbed]]
と呼ぶのは悪質。 [[プロトコルの脱共有化]]と言っても差し支えない。)
[36] [CITE@ja[embed機能 開発ガイドライン – noteヘルプセンター]], [TIME[2023-05-12T07:44:08.000Z]] <https://www.help-note.com/hc/ja/articles/900001827326/>