如何在不验证用户身份的情况下从 Instagram 获取用户的媒体?

我想把用户最近的 Instagram 媒体放到侧边栏。我想用 Instagram API 获取媒体。

Http://instagram.com/developer/endpoints/users/

文档说明了 GEThttps://api.instagram.com/v1/users/<user-id>/media/recent/,但是它说要传递一个 OAuth 访问令牌。访问令牌表示代表用户行事的授权。我不希望用户登录 Instagram 在侧边栏上看到这个。他们甚至不需要 Instagram 账号。

例如,我可以不用登录 Instagram 就可以进入 http://instagram.com/thebrainscoop查看照片。我想通过 API 来做这件事。

在 Instagram API 中,未经用户身份验证的请求传递的是 client_id而不是 access_token:

{
"meta":{
"error_type":"OAuthParameterException",
"code":400,
"error_message":"\"access_token\" URL parameter missing. This OAuth request requires an \"access_token\" URL parameter."
}
}

这不可能吗?是否有办法在不要求用户通过 OAuth 首先登录 Instagram 帐户的情况下获取用户的最新(公共)媒体?

210296 次浏览

Instagram API 要求通过 OAuth 进行用户身份验证,以访问用户最近的媒体端点。目前似乎没有任何其他方法可以为用户获取所有媒体。

如果您正在寻找一种方法来生成在单个帐户上使用的访问令牌,您可以尝试这种方法-> https://coderwall.com/p/cfgneq

我需要一种方法来使用 instagram 应用程序接口获取特定帐户的所有最新媒体。

如果你绕过 Oauth 你可能不会知道他们是哪个 instagram 用户。也就是说,有几种方法可以不经过身份验证就获得 instagram 图像。

  1. Instagram 的 API 允许您查看用户最受欢迎的图片,而无需进行身份验证

  2. Instagram 为 这个上的标记提供 rss 提要。

  3. Instagram 用户页面是公共的,因此您可以使用 PHP 和 CURL 来获取用户页面,并使用 DOM 解析器在 html 中搜索所需的图像标记。

这已经很晚了,但是如果能帮到某人的话是值得的,因为我在 Instagram 的文档中没有看到这一点。

要在 https://api.instagram.com/v1/users/<user-id>/media/recent/上执行 GET (在编写本文时) ,实际上不需要 OAuth 访问令牌。

你可以执行 https://api.instagram.com/v1/users/[USER ID]/media/recent/?client_id=[CLIENT ID]

[ CLIENT ID ]将是通过管理客户端在应用程序中注册的有效客户端 ID (与用户无关)。 您可以通过执行 GET 用户搜索请求从用户名获得[ USER ID ] : https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]

var name = "smena8m";
$.get("https://images"+~~(Math.random()*3333)+"-focus-opensocial.googleusercontent.com/gadgets/proxy?container=none&url=https://www.instagram.com/" + name + "/", function(html) {
if (html) {
var regex = /_sharedData = ({.*);<\/script>/m,
json = JSON.parse(regex.exec(html)[1]),
edges = json.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges;


$.each(edges, function(n, edge) {
var node = edge.node;
$('body').append(
$('<a/>', {
href: 'https://instagr.am/p/'+node.shortcode,
target: '_blank'
}).css({
backgroundImage: 'url(' + node.thumbnail_src + ')'
}));
});
}
});
html, body {
font-size: 0;
line-height: 0;
}


a {
display: inline-block;
width: 25%;
height: 0;
padding-bottom: 25%;
background: #eee 50% 50% no-repeat;
background-size: cover;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

You can download any Instagram user photo feed in JSON format using ?__a=1 next to landing page address like this. No need to get user id or register an app, no tokens, no oAuth.

min_id and max_id variables can be used for pagination, here is example

YQL may not work here inside snipped iframe, so you can always check it manually in YQL Console

APRIL 2018 UPDATE: After latest instagram updates you can't do this on client side (javascript) because custom headers for signed request can't be set with javascript due to CORS Access-Control-Allow-Headers restrictions. It still possible to do this via php or any other server side method with proper signature based on rhx_gis, csrf_token and request parameters. You can read more about it here.

JANUARY 2019 UPDATE: YQL retired, so, check my latest update with Google Image Proxy as CORS proxy for Instagram page! Then only negative moment - pagination not available with this method.

PHP solution:

    $html = file_get_contents('https://instagram.com/apple/');
preg_match('/_sharedData = ({.*);<\/script>/', $html, $matches);
$profile_data = json_decode($matches[1])->entry_data->ProfilePage[0]->graphql->user;

这是一个轨道解决方案,有点像后门,实际上就是前门。

# create a headless browser
b = Watir::Browser.new :phantomjs
uri = 'https://www.instagram.com/explore/tags/' + query
uri = 'https://www.instagram.com/' + query if type == 'user'


b.goto uri


# all data are stored on this page-level object.
o = b.execute_script( 'return window._sharedData;')


b.close

返回的对象取决于它是用户搜索还是标记搜索。我得到的数据是这样的:

if type == 'user'
data = o[ 'entry_data' ][ 'ProfilePage' ][ 0 ][ 'user' ][ 'media' ][ 'nodes' ]
page_info = o[ 'entry_data' ][ 'ProfilePage' ][ 0 ][ 'user' ][ 'media' ][ 'page_info' ]
max_id = page_info[ 'end_cursor' ]
has_next_page = page_info[ 'has_next_page' ]
else
data = o[ 'entry_data' ][ 'TagPage' ][ 0 ][ 'tag' ][ 'media' ][ 'nodes' ]
page_info = o[ 'entry_data' ][ 'TagPage' ][ 0 ][ 'tag' ][ 'media' ][ 'page_info' ]
max_id = page_info[ 'end_cursor' ]
has_next_page = page_info[ 'has_next_page' ]
end

然后,我通过以下方式构造一个 url,得到另一个页面的结果:

  uri = 'https://www.instagram.com/explore/tags/' + query_string.to_s\
+ '?&max_id=' + max_id.to_s
uri = 'https://www.instagram.com/' + query_string.to_s + '?&max_id='\
+ max_id.to_s if type === 'user'

只是想添加到@350D 答案,因为它对我来说很难理解。

接下来是我的代码逻辑:

当第一次调用 API 时,我只调用 < code > https://www.instagram.com/_vull_ /media/.当我收到响应时,我检查 more_available的布尔值。如果为真,则从数组中获取最后一张照片,获取其 ID,然后再次调用 Instagram API,但这次是 https://www.instagram.com/_vull_/media/?max_id=1400286183132701451_1642962433。译注:

这里需要知道的重要一点是,这个 Id 是数组中最后一张图片的 Id。因此,当使用数组中图片的最后一个 id 请求 maxId 时,将获得接下来的20个图片,以此类推。

希望这能澄清一些事情。

截至上周,Instagram 禁用了 /media/网址,我实现了一个解决方案,目前效果还不错

为了解决这个线程中每个人的问题,我编写了以下代码: https://github.com/whizzzkid/instagram-reverse-proxy

它使用以下端点提供 Instagram 的所有公共数据:

获取用户媒体:

https://igapi.ga/<username>/media
e.g.: https://igapi.ga/whizzzkid/media

获取具有限制计数的用户媒体:

https://igapi.ga/<username>/media?count=N // 1 < N < 20
e.g.: https://igapi.ga/whizzzkid/media?count=5

使用 JSONP:

https://igapi.ga/<username>/media?callback=foo
e.g.: https://igapi.ga/whizzzkid/media?callback=bar

代理 API 还将下一页和上一页的 URL 附加到响应中,因此您不需要在结束时计算它们。

希望你们喜欢!

感谢@350D 发现了这个:)

下面的 nodejs 代码从 Instagram 页面中提取流行图片。 “ ScrapeInstagramPage”函数负责处理后老化效应。

var request = require('parse5');
var request = require('request');
var rp      = require('request-promise');
var $       = require('cheerio'); // Basically jQuery for node.js
const jsdom = require("jsdom");
const { JSDOM } = jsdom;




function ScrapeInstagramPage (args) {
dout("ScrapeInstagramPage for username -> " + args.username);
var query_url = 'https://www.instagram.com/' + args.username + '/';


var cookieString = '';


var options = {
url: query_url,
method: 'GET',
headers: {
'x-requested-with' : 'XMLHttpRequest',
'accept-language'  : 'en-US,en;q=0.8,pt;q=0.6,hi;q=0.4',
'User-Agent'       : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
'referer'          : 'https://www.instagram.com/dress_blouse_designer/',
'Cookie'           : cookieString,
'Accept'           : '*/*',
'Connection'       : 'keep-alive',
'authority'        : 'www.instagram.com'
}
};




function dout (msg) {
if (args.debug) {
console.log(msg);
}
}


function autoParse(body, response, resolveWithFullResponse) {
// FIXME: The content type string could contain additional values like the charset.
// Consider using the `content-type` library for a robust comparison.
if (response.headers['content-type'] === 'application/json') {
return JSON.parse(body);
} else if (response.headers['content-type'] === 'text/html') {
return $.load(body);
} else {
return body;
}
}


options.transform = autoParse;




rp(options)
.then(function (autoParsedBody) {
if (args.debug) {
console.log("Responce of 'Get first user page': ");
console.log(autoParsedBody);
console.log("Creating JSDOM from above Responce...");
}


const dom = new JSDOM(autoParsedBody.html(), { runScripts: "dangerously" });
if (args.debug) console.log(dom.window._sharedData); // full data doc form instagram for a page


var user = dom.window._sharedData.entry_data.ProfilePage[0].user;
if (args.debug) {
console.log(user); // page user
console.log(user.id); // user ID
console.log(user.full_name); // user full_name
console.log(user.username); // user username
console.log(user.followed_by.count); // user followed_by
console.log(user.profile_pic_url_hd); // user profile pic
console.log(autoParsedBody.html());
}


if (user.is_private) {
dout ("User account is PRIVATE");
} else {
dout ("User account is public");
GetPostsFromUser(user.id, 5000, undefined);
}
})
.catch(function (err) {
console.log( "ERROR: " + err );
});


var pop_posts = [];
function GetPostsFromUser (user_id, first, end_cursor) {
var end_cursor_str = "";
if (end_cursor != undefined) {
end_cursor_str = '&after=' + end_cursor;
}


options.url = 'https://www.instagram.com/graphql/query/?query_id=17880160963012870&id='
+ user_id + '&first=' + first + end_cursor_str;


rp(options)
.then(function (autoParsedBody) {
if (autoParsedBody.status === "ok") {
if (args.debug) console.log(autoParsedBody.data);
var posts = autoParsedBody.data.user.edge_owner_to_timeline_media;


// POSTS processing
if (posts.edges.length > 0) {
//console.log(posts.edges);
pop_posts = pop_posts.concat
(posts.edges.map(function(e) {
var d = new Date();
var now_seconds = d.getTime() / 1000;


var seconds_since_post = now_seconds - e.node.taken_at_timestamp;
//console.log("seconds_since_post: " + seconds_since_post);


var ageing = 10; // valuses (1-10]; big value means no ageing
var days_since_post = Math.floor(seconds_since_post/(24*60*60));
var df = (Math.log(ageing+days_since_post) / (Math.log(ageing)));
var likes_per_day = (e.node.edge_liked_by.count / df);
// console.log("likes: " + e.node.edge_liked_by.count);
//console.log("df: " + df);
//console.log("likes_per_day: " + likes_per_day);
//return (likes_per_day > 10 * 1000);
var obj = {};
obj.url = e.node.display_url;
obj.likes_per_day = likes_per_day;
obj.days_since_post = days_since_post;
obj.total_likes = e.node.edge_liked_by.count;
return obj;
}
));


pop_posts.sort(function (b,a) {
if (a.likes_per_day < b.likes_per_day)
return -1;
if (a.likes_per_day > b.likes_per_day)
return 1;
return 0;
});


//console.log(pop_posts);


pop_posts.forEach(function (obj) {
console.log(obj.url);
});
}


if (posts.page_info.has_next_page) {
GetPostsFromUser(user_id, first, posts.page_info.end_cursor);
}
} else {
console.log( "ERROR: Posts AJAX call not returned good..." );
}
})
.catch(function (err) {
console.log( "ERROR: " + err );
});
}
}




ScrapeInstagramPage ({username : "dress_blouse_designer", debug : false});

试试 给你

例如: 对于给定的 URL‘ https://www.instagram.com/dress_blouse_designer/’,可以调用函数

ScrapeInstagramPage ({username : "dress_blouse_designer", debug : false});

2017年11月11日
由于 Instagram 改变了提供这些数据的方式,以上方法现在都不起作用了。以下是获取用户媒体的新方法:
接通 https://instagram.com/graphql/query/?query_id=17888483320059182&variables={"id":"1951415043","first":20,"after":null}
地点:
永久值: 17888483320059182(注意,将来可能会更改)。
用户的 id-id。它可能会附带用户列表。要获得用户列表,可以使用以下请求: GET https://www.instagram.com/web/search/topsearch/?context=blended&query=YOUR_QUERY
需要获得的项目数量。
如果要从最后一个项目中获取项目,则为该项目的 after-id。

我能够使用以下 API 获得用户的最新媒体,而不需要验证(包括描述、喜欢、评论计数)。

Https://www.instagram.com/apple/?__a=1

例如。

https://www.instagram.com/{username}/?__a=1

这使用一个简单的 ajax 调用和迭代图像路径。

        var name = "nasa";
$.get("https://www.instagram.com/" + name + "/?__a=1", function (data, status) {
console.log('IG_NODES', data.user.media.nodes);
$.each(data.user.media.nodes, function (n, item) {
console.log('ITEMS', item.display_src);
$('body').append(
"<div class='col-md-4'><img class='img-fluid d-block' src='" + item.display_src + "'></div>"
);
});
})

还有一个技巧,通过标签搜索照片:

GET https://www.instagram.com/graphql/query/?query_hash=3e7706b09c6184d5eafd8b032dbcf487&variables={"tag_name":"nature","first":25,"after":""}

地点:

query_hash-永久值(我相信它的哈希值17888483320059182,将来可以更改)

tag_name-标题不言自明

first-数量的项目得到(我不知道为什么,但这个价值不工作的预期。返回的照片的实际数量略大于值乘以4.5(值25大约为110,值100大约为460)

如果要从最后一个项目中获取项目,则为该项目的 after-id。可以在这里使用来自 JSON 响应的 end_cursor值。

JSFiddle

Javascript:

$(document).ready(function(){


var username = "leomessi";
var max_num_items = 5;


var jqxhr = $.ajax( "https://www.instagram.com/"+username+"/?__a=1" ).done(function() {
//alert( "success" );
}).fail(function() {
//alert( "error" );
}).always(function(data) {
//alert( "complete" )
items = data.graphql.user.edge_owner_to_timeline_media.edges;
$.each(items, function(n, item) {
if( (n+1) <= max_num_items )
{
var data_li = "<li><a target='_blank' href='https://www.instagram.com/p/"+item.node.shortcode+"'><img src='" + item.node.thumbnail_src + "'/></a></li>";
$("ul.instagram").append(data_li);
}
});


});


});

HTML:

<ul class="instagram">
</ul>

CSS:

ul.instagram {
list-style: none;
}


ul.instagram li {
float: left;
}


ul.instagram li img {
height: 100px;
}

多亏了 Instagram 不断变化的 API 模式(设计也非常糟糕) ,以上大部分模式到2018年4月将不再有效。

如果您使用 https://www.instagram.com/username/?__a=1方法直接查询各个发布数据的 API,以下是访问这些数据的最新路径。

假设返回的 JSON数据是 $data,您可以使用以下路径示例遍历每个结果:

foreach ($data->graphql->user->edge_owner_to_timeline_media->edges as $item) {


$content_id = $item->node->id;
$date_posted = $item-node->taken_at_timestamp;
$comments = $item->node->edge_media_to_comment->count;
$likes = $item->node->edge_liked_by->count;
$image = $item->node->display_url;
$content = $item->node->edge_media_to_caption->edges[0]->node->text;
// etc etc ....
}

最近变化的主要内容是 graphqledge_owner_to_timeline_media

看起来他们将要为 2018年12月中的非“业务”客户终止这种 API 访问,所以尽可能地利用它。

希望能帮到别人;)

好吧,由于 /?__a=1现在已经停止工作了,所以最好使用 curl 并解析 instagram 页面,就像下面这个答案所写的那样: 生成访问令牌 Instagram API,而不必登录?

您可以使用此 API 检索 instagram 用户的公共信息:

https://api.lityapp.com/instagrams/thebrainscoop?limit=2(编辑: 在2021年2月破坏/恶意链接)

如果不设置限制参数,则文章默认限制在12个

这个 API 是在 SpringBoot 用 htmlUnit 制作的,你可以在代码中看到:

    public JSONObject getPublicInstagramByUserName(String userName, Integer limit) {
String html;
WebClient webClient = new WebClient();
    

try {
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getCookieManager().setCookiesEnabled(true);
    

Page page = webClient.getPage("https://www.instagram.com/" + userName);
WebResponse response = page.getWebResponse();
    

html = response.getContentAsString();
} catch (Exception ex) {
ex.printStackTrace();
    

throw new RuntimeException("Ocorreu um erro no Instagram");
}
    

String prefix = "static/bundles/es6/ProfilePageContainer.js";
String suffix = "\"";
String script = html.substring(html.indexOf(prefix));
    

script = script.substring(0, script.indexOf(suffix));
    

try {
Page page = webClient.getPage("https://www.instagram.com/" + script);
WebResponse response = page.getWebResponse();
    

script = response.getContentAsString();
} catch (Exception ex) {
ex.printStackTrace();
    

throw new RuntimeException("Ocorreu um erro no Instagram");
}
    

prefix = "l.pagination},queryId:\"";
    

String queryHash = script.substring(script.indexOf(prefix) + prefix.length());
    

queryHash = queryHash.substring(0, queryHash.indexOf(suffix));
prefix = "<script type=\"text/javascript\">window._sharedData = ";
suffix = ";</script>";
html = html.substring(html.indexOf(prefix) + prefix.length());
html = html.substring(0, html.indexOf(suffix));
    

JSONObject json = new JSONObject(html);
JSONObject entryData = json.getJSONObject("entry_data");
JSONObject profilePage = (JSONObject) entryData.getJSONArray("ProfilePage").get(0);
JSONObject graphql = profilePage.getJSONObject("graphql");
JSONObject user = graphql.getJSONObject("user");
JSONObject response = new JSONObject();
    

response.put("id", user.getString("id"));
response.put("username", user.getString("username"));
response.put("fullName", user.getString("full_name"));
response.put("followedBy", user.getJSONObject("edge_followed_by").getLong("count"));
response.put("following", user.getJSONObject("edge_follow").getLong("count"));
response.put("isBusinessAccount", user.getBoolean("is_business_account"));
response.put("photoUrl", user.getString("profile_pic_url"));
response.put("photoUrlHD", user.getString("profile_pic_url_hd"));
    

JSONObject edgeOwnerToTimelineMedia = user.getJSONObject("edge_owner_to_timeline_media");
JSONArray posts = new JSONArray();
    

try {
loadPublicInstagramPosts(webClient, queryHash, user.getString("id"), posts, edgeOwnerToTimelineMedia, limit == null ? 12 : limit);
} catch (Exception ex) {
ex.printStackTrace();
    

throw new RuntimeException("Você fez muitas chamadas, tente mais tarde");
}
    

response.put("posts", posts);
    

return response;
}
    

private void loadPublicInstagramPosts(WebClient webClient, String queryHash, String userId, JSONArray posts, JSONObject edgeOwnerToTimelineMedia, Integer limit) throws IOException {
JSONArray edges = edgeOwnerToTimelineMedia.getJSONArray("edges");
    

for (Object elem : edges) {
if (limit != null && posts.length() == limit) {
return;
}
    

JSONObject node = ((JSONObject) elem).getJSONObject("node");
    

if (node.getBoolean("is_video")) {
continue;
}
    

JSONObject post = new JSONObject();
    

post.put("id", node.getString("id"));
post.put("shortcode", node.getString("shortcode"));
    

JSONArray captionEdges = node.getJSONObject("edge_media_to_caption").getJSONArray("edges");
    

if (captionEdges.length() > 0) {
JSONObject captionNode = ((JSONObject) captionEdges.get(0)).getJSONObject("node");
    

post.put("caption", captionNode.getString("text"));
} else {
post.put("caption", (Object) null);
}
    

post.put("photoUrl", node.getString("display_url"));
    

JSONObject dimensions = node.getJSONObject("dimensions");
    

post.put("photoWidth", dimensions.getLong("width"));
post.put("photoHeight", dimensions.getLong("height"));
    

JSONArray thumbnailResources = node.getJSONArray("thumbnail_resources");
JSONArray thumbnails = new JSONArray();
    

for (Object elem2 : thumbnailResources) {
JSONObject obj = (JSONObject) elem2;
JSONObject thumbnail = new JSONObject();
    

thumbnail.put("photoUrl", obj.getString("src"));
thumbnail.put("photoWidth", obj.getLong("config_width"));
thumbnail.put("photoHeight", obj.getLong("config_height"));
thumbnails.put(thumbnail);
}
    

post.put("thumbnails", thumbnails);
posts.put(post);
}
    

JSONObject pageInfo = edgeOwnerToTimelineMedia.getJSONObject("page_info");
    

if (!pageInfo.getBoolean("has_next_page")) {
return;
}
    

String endCursor = pageInfo.getString("end_cursor");
String variables = "{\"id\":\"" + userId + "\",\"first\":12,\"after\":\"" + endCursor + "\"}";
    

String url = "https://www.instagram.com/graphql/query/?query_hash=" + queryHash + "&variables=" + URLEncoder.encode(variables, "UTF-8");
Page page = webClient.getPage(url);
WebResponse response = page.getWebResponse();
String content = response.getContentAsString();
JSONObject json = new JSONObject(content);
    

loadPublicInstagramPosts(webClient, queryHash, userId, posts, json.getJSONObject("data").getJSONObject("user").getJSONObject("edge_owner_to_timeline_media"), limit);
}

这是一个反应的例子:

    {
"id": "290482318",
"username": "thebrainscoop",
"fullName": "Official Fan Page",
"followedBy": 1023,
"following": 6,
"isBusinessAccount": false,
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/447ffd0262082f373acf3d467435f130/5C709C77/t51.2885-19/11351770_612904665516559_678168252_a.jpg",
"photoUrlHD": "https://scontent-gru2-1.cdninstagram.com/vp/447ffd0262082f373acf3d467435f130/5C709C77/t51.2885-19/11351770_612904665516559_678168252_a.jpg",
"posts": [
{
"id": "1430331382090378714",
"shortcode": "BPZjtBUly3a",
"caption": "If I have any active followers anymore; hello! I'm Brianna, and I created this account when I was just 12 years old to show my love for The Brain Scoop. I'm now nearly finished high school, and just rediscovered it. I just wanted to see if anyone is still active on here, and also correct some of my past mistakes - being a child at the time, I didn't realise I had to credit artists for their work, so I'm going to try to correct that post haste. Also; the font in my bio is horrendous. Why'd I think that was a good idea? Anyway, this is a beautiful artwork of the long-tailed pangolin by @chelsealinaeve . Check her out!",
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/ab823331376ca46136457f4654bf2880/5CAD48E4/t51.2885-15/e35/16110915_400942200241213_3503127351280009216_n.jpg",
"photoWidth": 640,
"photoHeight": 457,
"thumbnails": [
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/43b195566d0ef2ad5f4663ff76d62d23/5C76D756/t51.2885-15/e35/c91.0.457.457/s150x150/16110915_400942200241213_3503127351280009216_n.jpg",
"photoWidth": 150,
"photoHeight": 150
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/ae39043a7ac050c56d741d8b4355c185/5C93971C/t51.2885-15/e35/c91.0.457.457/s240x240/16110915_400942200241213_3503127351280009216_n.jpg",
"photoWidth": 240,
"photoHeight": 240
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/ae7a22d09e3ef98d0a6bbf31d621a3b7/5CACBBA6/t51.2885-15/e35/c91.0.457.457/s320x320/16110915_400942200241213_3503127351280009216_n.jpg",
"photoWidth": 320,
"photoHeight": 320
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/1439dc72b70e7c0c0a3afcc30970bb13/5C8E2923/t51.2885-15/e35/c91.0.457.457/16110915_400942200241213_3503127351280009216_n.jpg",
"photoWidth": 480,
"photoHeight": 480
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/1439dc72b70e7c0c0a3afcc30970bb13/5C8E2923/t51.2885-15/e35/c91.0.457.457/16110915_400942200241213_3503127351280009216_n.jpg",
"photoWidth": 640,
"photoHeight": 640
}
]
},
{
"id": "442527661838057235",
"shortcode": "YkLJBXJD8T",
"caption": null,
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/dc94b38da679826b9ac94ccd2bcc4928/5C7CDF93/t51.2885-15/e15/11327349_860747310663863_2105199307_n.jpg",
"photoWidth": 612,
"photoHeight": 612,
"thumbnails": [
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/c1153c6513c44a6463d897e14b2d8f06/5CB13ADD/t51.2885-15/e15/s150x150/11327349_860747310663863_2105199307_n.jpg",
"photoWidth": 150,
"photoHeight": 150
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/47e60ec8bca5a1382cd9ac562439d48c/5CAE6A82/t51.2885-15/e15/s240x240/11327349_860747310663863_2105199307_n.jpg",
"photoWidth": 240,
"photoHeight": 240
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/da0ee5b666ab40e4adc1119e2edca014/5CADCB59/t51.2885-15/e15/s320x320/11327349_860747310663863_2105199307_n.jpg",
"photoWidth": 320,
"photoHeight": 320
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/02ee23571322ea8d0992e81e72f80ef2/5C741048/t51.2885-15/e15/s480x480/11327349_860747310663863_2105199307_n.jpg",
"photoWidth": 480,
"photoHeight": 480
},
{
"photoUrl": "https://scontent-gru2-1.cdninstagram.com/vp/dc94b38da679826b9ac94ccd2bcc4928/5C7CDF93/t51.2885-15/e15/11327349_860747310663863_2105199307_n.jpg",
"photoWidth": 640,
"photoHeight": 640
}
]
}
]
}

下面是一个 php 脚本,它下载图像并创建一个带有图像链接的 html 文件。信用350D 的 php 版本,这是刚刚阐述。.我会建议把这是一个老古董的工作和解雇无论你需要。截至2019年5月核实工作情况.

<?
$user = 'smena8m';
$igdata = file_get_contents('https://instagram.com/'.$user.'/');
preg_match('/_sharedData = ({.*);<\/script>/',$igdata,$matches);
$profile_data = json_decode($matches[1])->entry_data->ProfilePage[0]->graphql->user;
$html = '<div class="instagramBox" style="display:inline-grid;grid-template-columns:auto auto auto;">';
$i = 0;
$max = 9;
while($i<$max){
$imglink = $profile_data->edge_owner_to_timeline_media->edges[$i]->node->shortcode;
$img = $profile_data->edge_owner_to_timeline_media->edges[$i]->node->thumbnail_resources[0]->src;
file_put_contents('ig'.$i.'.jpg',file_get_contents($img));
$html .= '<a href="https://www.instagram.com/p/'.$imglink.'/" target="_blank"><img src="ig'.$i.'.jpg" /></a>';
$i++;
}
$html .= '</div>';
$instagram = fopen('instagram.html','w');
fwrite($instagram,$html);
fclose($instagram);
?>

我真的需要这个功能,但 WordPress。我适合,它完美地工作

<script>
jQuery(function($){
var name = "caririceara.comcariri";
$.get("https://images"+~~(Math.random()*33)+"-focus-opensocial.googleusercontent.com/gadgets/proxy?container=none&url=https://www.instagram.com/" + name + "/", function(html) {
if (html) {
var regex = /_sharedData = ({.*);<\/script>/m,
json = JSON.parse(regex.exec(html)[1]),
edges = json.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges;
$.each(edges, function(n, edge) {
if (n <= 7){
var node = edge.node;
$('.img_ins').append('<a href="https://instagr.am/p/'+node.shortcode+'" target="_blank"><img src="'+node.thumbnail_src+'" width="150"></a>');
}
});
}
});
});
</script>

如果希望搜索没有 clientID 和访问令牌的用户:

1: 如果你想搜索所有名字与搜索词相似的用户:

用要搜索的文本替换 SeachName:

Https://www.instagram.com/web/search/topsearch/?query=searchname

2: 如果你想搜索完全相同的名字用户:

将 UserName 替换为所需的搜索名称:

Https://www.instagram.com/username/?__a=1