Instagram ID到用户名 [英] Instagram ID to username

查看:258
本文介绍了Instagram ID到用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您拥有instagram ID时,是否可以获取instagram用户名?如果是,请显示示例.

Is it possible to get the instagram username when you have the instagram ID? If yes please show an example.

我在互联网上看到有人谈论API,他们使用的链接如下所示:

I have seen in the internet people talking about an API and they use a link which looks like the following:

https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN

推荐答案

是的,请尝试

async function insta(uid) {
  let api = `https://i.instagram.com/api/v1/users/${uid}/info/`
  let info = await (await fetch(api)).json();
  return "https://www.instagram.com/" + info.user.username;
}

async function go() {
  let url = await insta(txt.value)
  link.innerText = link.href = url;
}

Type instagram user id:
<input id="txt" value=1791879548 />
<button onclick="go()">GO!</button><br>
<pre id="link"></pre>

根据

According this starting form 03.12.2019 above solution stops works and returns only

{消息":用户代理不匹配",状态":失败"}

{"message": "useragent mismatch", "status": "fail"}

但是-您可以尝试发送请求GET

however - you can try to send request GET

https://i.instagram.com/api/v1/users/1791879548/info/

具有以下用户代理标头:

with following user-agent header:

Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Instagram 105.0.0.11.118 (iPhone11,8; iOS 12_3_1; en_US; en-US; scale=2.00; 828x1792; 165586599)

这篇关于Instagram ID到用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆