通过php通过标签获取Instagram照片

问题描述 投票:-1回答:2

我先通过file_get_contents抓取数据,然后再抓取preg_match张照片,它已经可以使用两年了,但是现在停止了。 Insta拒绝并加载空白的html页面。您知道如何解决它吗?

<?
file_get_contents("https://www.instagram.com/explore/tags/roofers");
preg_match( "/window._sharedData \=(.+),\"is_canary/im", $str, $matches );
...
?>
php instagram file-get-contents
2个回答
0
投票

Instagram使用此链接重定向到登录页面。我不是Instagram粉丝,所以我只能假定此链接曾经未经授权打开。最有可能的是,您首先需要经过授权(例如,使用curl),然后才可以访问内容链接。


0
投票

Instagram更改了身份验证规则,只有登录的用户现在可以访问公共照片。您可以改用Instagram API。

https://developers.facebook.com/docs/instagram-api/reference/user/media#get-media

© www.soinside.com 2019 - 2024. All rights reserved.