代码之家  ›  专栏  ›  技术社区  ›  johnny_mac

我在哪里可以从这个url获得instagram快捷码

  •  2
  • johnny_mac  · 技术社区  · 7 年前

    我已经使用Instagram API有一段时间了,但我看到一个url给我带来了问题。到目前为止,我一直在从这样的url中提取短代码:

    const instagramRegex = /https:\/\/www.instagram.com\/p\/([\w-]+)\/?/g;
    let shortcode = instaRegex.exec(url)[1];
    

    这将按预期返回短代码,类似于url中的BU89NChA8Cz https://www.instagram.com/p/BU89NChA8Cz/ .现在的问题是,以下url返回html,而不是预期的json响应。它也不太可能是一个短码。

    问题url: https://www.instagram.com/p/BTC-qwADp7WmlJ06W_Z_B59Bxbpml31t_fb-3U0/

    我还尝试了这个较大代码的变体,在“_”上拆分,但每个都返回“无效的媒体id”

    我做错了什么?

    1 回复  |  直到 7 年前
        1
  •  2
  •   krisrak    7 年前

    它是来自私有配置文件的URL,因此您无法查看它。

    通常,如果来自Instagram用户的短代码很长,并且是私有的,那么如果该用户允许,并且您登录到Instagram.com,则该URL将起作用