我正在查找已上传的 Instagram 图像的 "MediaID"。它应该看起来像
1234567894561231236_33215652
我发现最后一组整数是用户 ID
例如:这是图片的直接链接,但我没有看到正确格式的 mediaID
?
http://distilleryimage11.ak.instagram.com/d33aafc8b55d11e2a66b22000a9f09de_7.jpg
而这是链接
http://instagram.com/p/Y7GF-5vftL/
我不希望使用 API,因为我只需要所选图片的媒体 ID。
∮ Here's a better way:
http://api.instagram.com/oembed?url=http://instagram.com/p/Y7GF-5vftL/
渲染为 json 对象,你可以轻松从中提取媒体 ID ---
例如,在 PHP中
$api = file_get_contents("http://api.instagram.com/oembed?url=http://instagram.com/p/Y7GF-5vftL/");
$apiObj = json_decode($api,true);
$media_id = $apiObj['media_id'];
例如,在 JS 中
$.ajax({
type: 'GET',
url: 'http://api.instagram.com/oembed?callback=&url=http://instagram.com/p/Y7GF-5vftL/',
cache: false,
dataType: 'jsonp',
success: function(data) {
try{
var media_id = data[0].media_id;
}catch(err){}
}
});
您的媒体 ID 是448979387270691659_45818965
如何获取
1.访问 instgram.com/username。
2.点击你想要id的照片。
3.(Chrome 浏览器说明)右键单击照片(应弹出图像)
4.检查元素
5.搜索选中的文本,你应该会看到类似这样的内容 photo448979387270691659_45818965
。
这应该就是你的身份证照片。
由于某些原因,这似乎只对弹出窗口有效,而对实际的图片 URL 无效。
纯 JS(前提是你的浏览器能处理 XHR,所有主流浏览器(包括 IE > 6)都能):
function igurlretrieve(url) {
var urldsrc = "http://api.instagram.com/oembed?url=" + url;
//fetch data from URL data source
var x = new XMLHttpRequest();
x.open('GET', urldsrc, true);
x.send();
//load resulting JSON data as JS object
var urldata = JSON.parse(x.responseText);
//reconstruct data as "instagram://" URL that can be opened in iOS app
var reconsturl = "instagram://media?id=" + urldata.media_id;
return reconsturl;
}
如果这是你的目标--只需在 Instagram iOS 应用程序中打开页面,而这正是我们要做的--这就够了,尤其是如果你不想支付许可费的话。