B
B
bublik13372018-11-21 15:48:06
PHP
bublik1337, 2018-11-21 15:48:06

How to get a direct link to ava instagram?

How to get a direct link to ava instagram?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Egor Davydov, 2018-11-21
@bublik1337

And here's an even easier way than parsing HTML.
We make a request to the address " https://www.instagram.com/{username}/?__a=1 ", where {username} is the nickname of the desired user.

$username = "tregor_live";

$response = file_get_contents("https://www.instagram.com/{$username}/?__a=1");
$acccount = json_decode($response, true);

In response, we get a JSON object with account data, including an avatar.
Specifically, the link to the avatar lies in
or in
"$account['graphql']['user']['profile_pic_url_hd']"

M
MarmaladeKnight, 2018-11-21
@MarmaladeKnight

We open the developer console, look at the desired element with the inspector, voila, this is how Ava's element looks on Instagram
The link will be a file of 150x150 pixels, which is the ava of the profile you need

A
Alexey Istomin, 2020-04-20
@webistomin

I wrote a small library for such a case ( link to github ). It turned out to be only 2Kb and does not require access_token and client_id from Instagram.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question