How to get Instagram Profile Picture

Hi Folks!

I have around 600 stores registered at my app and I’d like to replace their profile picture with their own profile picture from Instagram profiles. Almost all of them have an IG profile, so it will help me to replace the image for about 90% of stores. The question is… How to get it from IG?

Did some of you already faced this challenge ?

Thanks in advance!

Hello Vitor!

Instagram outputs information about accounts in JSON format when you request it via their web API.

https://www.instagram.com/USERNAMEHERE/?__a=1

Under “profile_pic_url” or “profile_pic_url_hd”, there will be a link to the profile picture.
There might be easier ways to do this, but I have found that this is the easiest (and free) way to do it.

Made a demo sheet that uses ImportJSON (a addon)

2 Likes

Wow!! Really cool! Thanks so much!

An alternative way here.

1 Like

Apart from Instagram, this can help you.

https://s.gravatar.com/avatar/{email_id}?s=1000

https://graph.facebook.com/{user.id}/picture?width=400&height=400

2 Likes

For a gravatar image, you need to put hash value.

I’ve used this method to get 1000 attendees for a developer conference check-in app a year ago.

So, in a google sheet use the apps script code to get the md5 value of email id.

Here is a code

function MD5 (input) {
var rawHash = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, input);
var txtHash = ‘’;
for (i = 0; i < rawHash.length; i++) {
var hashVal = rawHash[i];
if (hashVal < 0) {
hashVal += 256;
}
if (hashVal.toString(16).length == 1) {
txtHash += ‘0’;
}
txtHash += hashVal.toString(16);
}
return txtHash;
}

Now, Get back to sheets. And use function =md5(email column value)

then simply use url https://s.gravatar.com/avatar/{email_id_md5}?s=1000

3 Likes

Fantastic! Thanks so much!

2 Likes