无法获得全尺寸的 instagram 个人资料图片

YAS*_*p10 4 java profile android image instagram

几天前,我能够通过从 pic URL 中删除 vp/ 并将分辨率从s150x150更改为s720x720来获取我的 android 应用程序中的个人资料图片以获取exp,它工作正常,但现在我仍然得到“无效的 url 签名”,所以我认为 instagram 已经在他们的 url 中添加了签名,我通常在 pic URL 中将 parte 从 vp/ 删除到 /t51 ......就像这样

https://scontent-mxp1-1.cdninstagram.com/ VP / XXXXXXXX /t51....jpg
,但它不工作!

我不知道 instagram 发生了什么,所以有人可以帮我找到解决这个问题的方法吗?或者另一种方法。谢谢

SUM*_*UM1 5

以下是截至 2020 年 5 月没有外部网站(如https://www.instadp.com/)的情况。程序也可以使用这种 API 方法。

  • 首先,请确保您在要执行此操作的浏览器上登录了 Instagram 帐户。

  • 在此 URL 中输入用户名代替“usernamehere”:

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

  • 访问网址。

  • 复制开头“profilePage_”后的数字。这是用户 ID。(它也位于下graphql.user.idJSON)。

  • 粘贴此 URL 中的数字代替“此处的数字”

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

  • 访问网址。您很可能会看到{"message": "useragent mismatch", "status": "fail"}. 如果这样做,请执行以下步骤:

  • 如果您使用的是 Chrome,请按 F12 或 Ctrl+Shift+I 或 Ctrl+Shift+J 打开 DevTools。

  • 在底部绘图中(您可以看到“控制台”、“新增功能”、“网络条件”),单击“网络条件”。

  • 在“用户代理”下,取消选中“自动选择”。

  • 选择“自定义...”,然后将 Instagram 移动用户代理粘贴到框中,如下所示:

Mozilla/5.0 (Linux; Android 9; GM1903 Build/PKQ1.190110.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36 Instagram/537.36 Instagram.190110.0019 Android (Android 103.180.19) ; 420dpi; 1080x2260; OnePlus; GM1903; OnePlus7; qcom; sv_SE; 164094539)

您可以在此处找到更多信息

  • 不要关闭 DevTools。刷新页面。

    注意:有些浏览器扩展可以做到这一点。

    查看本教程以了解如何在其他浏览器上执行此操作。

  • 按 Ctrl+F,然后搜索“hd_profile_pic_url_info”。

  • 复制“url”和“width”之间的 URL。篇幅较长,请仔细看。(它位于user.hd_profile_pic_url_info.urlJSON 下。)

注意:像这样的扩展将使这一部分变得更加容易。

  • 将 URL 粘贴到地址栏中,但不要按 Enter。

  • 在 URL 中查找“\u0026”的所有实例。应该有大约 3 个,在 URL 的后半部分。这些是“&”的 JavaScript 代码,但它们在地址栏 URL 中不起作用(Bad URL timestamp如果按 Enter,您将看到)。将它们全部替换为“&”。

  • 访问网址。

现在您拥有全分辨率的个人资料图片。:)

更新:终于开始编写一个函数来获取这个 URL。您可以在浏览器中使用它,而不必执行所有这些步骤。

async function fetchIGProfilePic(input) {
    if (!/^https?:\/\/i.instagram.com\//.test(window.location.href)) {
        if (window.confirm('fetchIGProfilePic:\n\nWe need to navigate to i.instagram.com for the request to work. (We need to make the request from the same domain as the profile pic API; CORS policy.) Please run the script after doing this.\n\nNavigate to i.instagram.com? (Ignore the 404 error.)')) {
            window.location.href = 'https://i.instagram.com/api/v1/';
            return;
        } else {
            return 'fetchIGProfilePic: Cancelled.';
        }
    }
    let response;
    let output;
    try {
        response = await fetch('https://www.instagram.com/' + input + '/?__a=1');
        if (!response.ok) {
            console.log('Failed 1st step, to fetch userID, with bad response status:' + response.status);
            return;
        }
    } catch(error) {
        console.log('Failed 1st step, to fetch userID, with ok response status: ' + error);
        return;
    }
    let userData = await response.json();
    try {
        response = await fetch('https://i.instagram.com/api/v1/users/' + userData.graphql.user.id + '/info/', {
            // The following doesn't seem to be necessary in a console request, but I kept it in in case you have issues at this stage.
            headers: {'user-agent': 'Mozilla/5.0 (Linux; Android 9; GM1903 Build/PKQ1.190110.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36 Instagram 103.1.0.15.119 Android (28/9; 420dpi; 1080x2260; OnePlus; GM1903; OnePlus7; qcom; sv_SE; 164094539)'
            }
        });
        if (!response.ok) {
            console.log('Failed 2nd step, to fetch profile pic URL, with bad response status: ' + response.status);
            window.alert('fetchIGProfilePic:\n\nYou might not be logged in, which is necesary for the request to work. Please log into an Instagram account, then run this script again.');
            return;
        }
    } catch(error) {
        console.log('Failed 2nd step, to fetch profile pic URL, with ok response status: ' + error);
        return;
    }
    let profileData = await response.json();
    console.log('Full-size profile pic URL of ' + input + ':\n' + profileData.user.hd_profile_pic_url_info.url);
}

fetchIGProfilePic('instagram'); // Enter the username here.
Run Code Online (Sandbox Code Playgroud)

在浏览器中,按 F12 打开控制台,然后粘贴脚本。将用户名放在底部括号中,然后按 Enter,它会在控制台中检索 URL。确保您在https://i.instagram.com/api/v1/ 上并在运行脚本时登录了 Instagram 帐户。