上下文
我有一段(jQuery)ajax 代码,直到最近几周左右,它已经愉快地工作了大约 9 个月。
此代码使用 Instagram 的嵌入端点 http://instagram.com/developer/embedding/这使我能够从正常的 Instagram 链接中获取媒体源(图像或视频),例如http://instagram.com/p/BUG/
无论用户和without需要一个access_token
.
简化示例:
var URL = "http://api.instagram.com/oembed?url=http://instagram.com/p/BUG/";
$(document).ready(function () {
$.ajax({
url: URL,
dataType: "jsonp",
cache: false,
success: function (response) {
console.log(response.url);
},
error: function () {
console.log("couldn't process the instagram url");
}
});
});
在上面的代码中,response.url
将返回完整的媒体 URL 源,例如:
http://photos-a.ak.instagram.com/xxxx/1234_123456123_123456_n.jpg // image or
http://distilleryvesper3-15.ak.instagram.com/b0c957463548362858_101.mp4 // video
然后我可以使用返回的 URL 将媒体文件嵌入到我的网页中。
NOTE :
由于我们的想法是获取任何 Instagram 链接的 URL 源(无论用户是谁),因此使用媒体端点 http://instagram.com/developer/endpoints/media/#不是一个选择。
问题
Instagram oembed 端点允许您获取json
响应,直到最近几周为止,其结构如下:
{
"provider_url" : "http:\/\/instagram.com\/",
"media_id" : "123456789_123456789",
"title" : "the title",
"url" : "http:\/\/photos-a.ak.instagram.com\/hphotos-ak-xfp1\/12345678_123456789012345_1234567890_n.jpg",
"author_name" : "{the user name}",
"height" : 640,
"width" : 640,
"version" : "1.0",
"author_url" : "http:\/\/instagram.com\/{the user name}",
"author_id" : 123456789,
"type" : "photo",
"provider_name" : "Instagram"
}
正如您可能注意到的,我的 ajax 代码对属性名称特别感兴趣url
,其中包含完整媒体的 URL。
Notice那个这个json
响应(和今天一样)对于 Instagram 图片仍然有效,however,如果原来Instagram的链接是视频,我们用一个真实的例子:http://instagram.com/p/mOFsFhAp4f/ http://instagram.com/p/mOFsFhAp4f/(可口可乐(c))json
响应不返回任何内容url
不再是钥匙了。
看来引进之后网络嵌入 http://blog.instagram.com/post/55095847329/introducing-instagram-web-embedsInstagram 决定更换密钥url
by a html
仅适用于视频的 (oembed) json 响应中的属性,其中包含要嵌入的 iframe,如下所示:
{
...
"html" : "\u003ciframe src=\"http:\/\/instagram.com\/p\/BUG\/embed\" width=\"616\" height=\"716\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\"\u003e\u003c\/iframe\u003e",
...
}
...当然,这破坏了我的代码,因为response.url
未定义。
问题
Instagram json 响应发生更改后,如何获取完整视频的 URL?
不幸的是,我在 Instagram 的开发者网站上找不到任何合适的文档或更改日志(他们有很棒的 API,但文档很差。)
Please notice该问题是关于 Instagram API (v1) 嵌入端点而不是 jQuery 或 ajax 问题。
我正在寻找(可能是未记录的)Instagram 的 API 选项、端点、oembed 或其他(不需要access_token
),这使我能够从正常的 Instagram 链接中检索到媒体视频的直接链接(最好是在 json 响应之后),无论用户如何……或者愿意考虑一个不太黑客的解决方法。