有没有办法在不登录的情况下用PHP拉instagram提要? [英] Is there a way to pull an instagram feed with PHP without logging in?
问题描述
似乎该解决方案不再有效-
It seems that this solution no longer works -
新的API需要访问令牌,该令牌在通过登录页面后会动态分配.有没有办法通过PHP仍以编程方式提取供稿,而无需跳过新的oauth箍?这对于将crontab设置为自动将新帖子保存到数据库很有用.
The new API requires an access token which is dynamically assigned after passing through a login page. Is there a way to still pull a feed programmatically through PHP without jumping through the new oauth hoops? This is useful for setting a crontab to automatically save new posts to a database.
推荐答案
可以.您无需登录或access_token即可获取最新的20条帖子.您只需要解析https://www.instagram.com/[USERNAME]/media/
中的json内容.
将[username]
替换为instagram user_name
.
Yes you can. You don't need to login or access_token to get the latest 20 posts. You just need to parse the json content from https://www.instagram.com/[USERNAME]/media/
.
Replace the [username]
with the instagram user_name
.
例如
$instaResult = file_get_contents('https://www.instagram.com/'.$username.'/media/');
$insta = json_decode($instaResult);
更新: Instagram已经更改了用户媒体的rss url.为了获得rss feed,您现在必须使用 https://www.instagram.com/[USERNAME]/?__ a = 1
UPDATE: Instagram has changed the user media rss url. In order to get the rss feed you now have to use https://www.instagram.com/[USERNAME]/?__a=1
更新:
最好使用基于curl
或Psr\Http\Message\RequestInterface
的库,例如 http: //docs.guzzlephp.org/en/stable/
UPDATE:
Instead of file_get_contents
, it is better to use curl
or Psr\Http\Message\RequestInterface
based library like http://docs.guzzlephp.org/en/stable/
这篇关于有没有办法在不登录的情况下用PHP拉instagram提要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!