Do you want to display your instagram feed on your website while enjoying the performance of locally hosted images?
Instafeed grabs the last 20 posts of your instagram feed, downloads and stores the images locally and serves an updated json. It also includes an access token generator.
- Clone this repository.
- Pastes the contents of
config.sample.php
toconfig.php
and update it with your credentials. You'll need an access token for this. If you don't have one, see Generate Access Token. - Serve it on your local machine by pasting
php -S localhost:8000
in your terminal. - Access
localhost:8000
for the json orlocalhost:8000/example.html
for an example.
- php installed
- Write access in the root folder of this script, because folders and files are written for caching.
- An instagram account
- Register at https://instagram.com/developer
- Click
Manage Clients
and follow their instructions to register a new client - Click
Manage
on your newly created client to get theClient ID
andClient Secret
at the top of the page. Basic permissions are enough for this. - EITHER
- Use an online service to generate your access token. OR
- Use the following instructions to use the included access token generator.
- Go the the settings of your client again, where you found the secret and id.
- Click
Security
and pastehttp://localhost:8000/generate_access_token.php
or your config'sREDIRECT_URI
into theValid redirect URIs
field. - Start you local server with
php -S localhost:8000
and browse tohttp://localhost:8000/generate_access_token.php
and your newly generated access token should be printed on the screen. - Copy and paste the generated access code into the corresponding field in your
config.php
.
The included example.html is only a very rough sketch how to use this tool, although it shows how you can use this tool. You now have all images locally cached and a json with updated urls to your cached files. Go create your own amazing websites with these or just store your instagram images.
- This tool only caches the last 20 posts on your instagram account. Older images are also deleted from the cache.
- So far, only image-posts and carousel-image-posts are processed. Videos are not supported.
To deploy this service, you'll need to change some variables. Most, if not all changes can (and should) be done in the config.php
.
Joshua Stübner - joshuastuebner.com
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
Thank you to InstaFeed.js for inspiration.