【问题标题】:can't get instagram profile picture full size无法获得 instagram 个人资料图片全尺寸
【发布时间】:2018-02-07 11:41:52
【问题描述】:

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

https://scontent-mxp1-1.cdninstagram.com/vp/xxxxxxxx/t51....jpg
但它不起作用!

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

【问题讨论】:

    标签: java android image instagram profile


    【解决方案1】:

    以下是截至 2020 年 5 月在没有像 https://www.instadp.com/ 这样的外部网站的情况下的操作方法。程序也可以使用此 API 方法。

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

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

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

    • 访问网址。

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

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

    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 103.1.0.15.119 Android ( 28/9;420dpi;1080x2260;一加;GM1903;一加7;qcom;sv_SE;164094539)

    您可以找到更多here

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

      注意:有browser extensions 可以做到这一点。

      查看this tutorial,了解如何在其他浏览器上执行此操作。

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

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

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

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

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

    • 访问网址。

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

    更新:终于开始编写一个函数来获取这个 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.
    

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

    【讨论】:

    • 这可以在应用中实现吗?
    猜你喜欢
    • 2012-01-24
    • 1970-01-01
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多