首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Instagram URL -> JSON

Instagram URL -> JSON
EN

Stack Overflow用户
提问于 2016-06-17 03:41:31
回答 1查看 1.2K关注 0票数 1

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

我不能使用API,因为我需要公共哈希标签内容,我的用例将不符合他们的应用审查过程:-(。

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

代码语言:javascript
复制
$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>';
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-17 10:49:15

在这里看一下这个解决方案:https://github.com/Bolandish/Instagram-Grabber

这是我至今所知道的最好的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37872756

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档