我不是 100% 确定这是否与 Youtube 的端点有关,如果我做错了什么。
当我在 WordPress 中嵌入 Youtube 视频时,问题就出现了。我通过 WordPress 核心进行了所有调试,并将其缩小到来自 Youtube 端点的响应,该端点从 youtube 返回 oEmbed。
端点:
https://www.youtube.com/oembed?maxwidth=640&maxheight=960&url=youtu.be%2FI0dQx4SNSwE&format=json
响应(原始):
{"thumbnail_height": 360, "width": 640, "thumbnail_width": 480, "provider_url": "http:\/\/www.youtube.com\/", "html": "\u003ciframe width=\"640\" height=\"360\" src=\"http:\/\/www.youtube.com\/embed\/I0dQx4SNSwE?feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e)", "height": 360, "type": "video", "version": "1.0", "title": "Why Do We Yawn?", "author_name": "AsapSCIENCE", "thumbnail_url": "http:\/\/i1.ytimg.com\/vi\/I0dQx4SNSwE\/hqdefault.jpg", "provider_name": "YouTube", "author_url": "http:\/\/www.youtube.com\/user\/AsapSCIENCE"}
响应:(格式化)
{
"thumbnail_height": 360,
"version": "1.0",
"provider_name": "YouTube",
"thumbnail_url": "http://i1.ytimg.com/vi/I0dQx4SNSwE/hqdefault.jpg",
"title": "Why Do We Yawn?",
"html": "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/I0dQx4SNSwE?feature=oembed\" frameborder=\"0\" allowfullscreen></iframe>)",
"provider_url": "http://www.youtube.com/",
"type": "video",
"height": 360,
"author_url": "http://www.youtube.com/user/AsapSCIENCE",
"thumbnail_width": 480,
"author_name": "AsapSCIENCE",
"width": 640
}
正如您在“html”属性的末尾看到的那样,有一个额外的“/iframe\u003e)”
我做错了什么还是 Youtube 有什么问题?我说不出话来。我真的很想认为 Youtube 会足够聪明,不会返回这样的东西,所以我不得不认为这是我做错了......