It seems that this solution no longer works –
How to get a user’s Instagram feed
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.
Advertisement
Answer
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
.
eg.
$instaResult = file_get_contents('https://www.instagram.com/'.$username.'/media/'); $insta = json_decode($instaResult);
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
UPDATE:
Instead of file_get_contents
, it is better to use curl
or PsrHttpMessageRequestInterface
based library like http://docs.guzzlephp.org/en/stable/