Instagram URL --> JSON



我该如何使用PHP将公共Instagram URL转换为JSON?例如:https://www.instagram.com/explore/tags/brindle/

我无法使用API,因为我需要公共标签内容,并且我的用例不符合其应用程序审核过程: - (。

这是我到目前为止所拥有的,但并未吸引所有图像。另外,我也希望能够加载"更多加载"图像。任何帮助将不胜感激!

$instagram_source = file_get_contents("https://www.instagram.com/explore/tags/brindle/");
$instagram_data = explode("window._sharedData = ", $instagram_source);
$instagram_json = explode(';</script>', $instagram_data[1]);
$instagram_array = json_decode($instagram_json[0], TRUE);
$instagram_media = $instagram_array['entry_data']['TagPage'][0]['tag']['media']['nodes'];
if(!empty($instagram_media)) {
echo '<ul>';
foreach($instagram_media as $im) {
echo '<li>';
    echo '<a href="https://www.instagram.com/p/'.$im['code'].'/" target="_blank">';
        echo '<img src="'.$im["display_src"].'" alt="" width="'.$im["dimensions"]["width"].'" height="'.$im["dimensions"]["height"].'" />';
    echo '</a>';
echo '</li>';
}
echo '</ul>';
}

在此处查看此解决方案:https://github.com/bolandish/instagram-grabber

那是我到目前为止所知道的最好的。

最新更新