通过ID查找Instagram媒体网址 [英] Find Instagram media url by ID
问题描述
由于不是非常正式的HTTP调用,我发现了媒体ID,图像URL和Instagram帖子的用户名.
Thanks to a HTTP call not very official, I find media ID, image URL, and user name of Instagram posts.
但是我需要Instagram上每条帖子的URL,而且我不知道如何找到它.
But I need the URL of each post on Instagram, and I don't know how to find it.
是否存在像instagram.com/something/{mediaID}
这样的URL重定向到instagram.com/p/{mediaSlug}
,还是通过媒体ID查找的另一种方法(当然不使用官方API!)?
Is there an URL like instagram.com/something/{mediaID}
which redirect to instagram.com/p/{mediaSlug}
, or another method to find slug by media ID (without using the official API of course!) ?
例如,我有:
唯一编号:1238578393243739039028_1408429375
Unique number : 1238578393243739028_1408429375
媒体ID:1238578393243739028
Media ID : 1238578393243739028
用户ID:1408429375
User ID : 1408429375
我会的:
感谢您的帮助!
推荐答案
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;
}
这篇关于通过ID查找Instagram媒体网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!