Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 如何从媒体共享URL获取Instagram帖子的URL?_Json_Url_Instagram - Fatal编程技术网

Json 如何从媒体共享URL获取Instagram帖子的URL?

Json 如何从媒体共享URL获取Instagram帖子的URL?,json,url,instagram,Json,Url,Instagram,当您请求下载Instagram个人资料数据时,您的对话将保存在JSON文件中。会话中的共享帖子在JSON文件中转换为以下内容: { "sender": "username", "created_at": "2021-02-29T05:34:34.866155+00:00", "media_owner": "bloombergbusiness", "me

当您请求下载Instagram个人资料数据时,您的对话将保存在JSON文件中。会话中的共享帖子在JSON文件中转换为以下内容:

{
  "sender": "username",
  "created_at": "2021-02-29T05:34:34.866155+00:00",
  "media_owner": "bloombergbusiness",
  "media_share_caption": "The world is finally losing its taste for meat. Last year was only the second since 1961 in which meat production fell and it’s headed for another decline this year.\n\nBeef is clearly declining as a percentage of total meat production—that’s huge for the climate. Emissions from its production are about 10 times higher than from either pork or chicken. \n\nNow investors are betting more than $1 billion on alternative proteins this year. Click the link in our bio to read more.",
  "media_share_url": "https://scontent-atl3-1.cdninstagram.com/v/t51.2885-15/fr/e15/s1080x1080/116427336_158250425871714_8283380464202749985_n.jpg?_nc_ht=scontent-atl3-1.cdninstagram.com&_nc_cat=106&_nc_ohc=InoAagAFZN4AX_f89en&oh=4337b2808755d718c329088688ba9fcd&oe=5F5AF234&ig_cache_key=MjM2NTE4MTQ2Mzk1OTE2MDM1MQ%3D%3D.2"
}
URLìn
media_share\u URL
是短暂的,因此在一段时间后它将过期,只需返回“URL签名过期”

我的问题是:

有没有办法从该
媒体\u共享\u URL
获取原始URL?在上面的例子中,这将是。或者,也可以得到一份工作


这可能吗?

如果你有这些信息,你可以使用它

  • 媒体ID
  • 邮政ID
  • 你可以试着用它们

    Java代码:

       public static String getInstagramPostId(String mediaId) {
        String postId = "";
        try {
            long id = Long.parseLong(mediaId.substring(0, mediaId.indexOf('_')));
            String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
    
            while (id > 0) {
                long remainder = (id % 64);
                id = (id - remainder) / 64;
                postId = alphabet.charAt((int)remainder) + postId;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    
        return postId;
     }
    
    您可以检查此链接中的javascript


    ()

    谢谢您的回复。您能否提供一个关于问题中的
    媒体共享\u url
    的工作示例?另外,为了澄清,如问题中所述,我没有de media ID,但是
    media\u share\u url
    ,它们是不同的。