retinens / laravel-instagram
A laravel wrapper to use instagram API and to cache posts
Installs: 229
Dependents: 0
Suggesters: 0
Security: 0
Stars: 77
Watchers: 5
Forks: 15
Open Issues: 2
Requires
- php: ^7.2
- ext-json: *
- illuminate/config: 5.8.*|^6.0|^7.0
- illuminate/support: 5.8.*|^6.0|^7.0
- php-http/guzzle6-adapter: ^2.0
- php-http/message: ^1.8
- vinkla/instagram: ^9.3
Requires (Dev)
- orchestra/testbench: 3.8.*
- php-http/mock-client: ^1.3
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-12-14 19:13:01 UTC
README
This package adds an Instagram post model to your Laravel application, for a cool feed or something like this.
The package relies on the vinkla/instagram
package, and adds a solution to cache and a model
Installation
You can install the package via composer:
composer require retinens/laravel-instagram
Then run the migrations used for caching, as the API is limited to 200 calls/hour.
php artisan migrate
Usage
First you need to generate an access token using Pixel Union's access token generator or by creating an Instagram application.
Put this API key in your .env file
INSTAGRAM_KEY=YOUR_KEY
You can run the command to update the cache.
php artisan laravel-instagram:refresh
NOTE : you have to run the Laravel Scheduler in background to use this package. This package adds a command which is executed every 10 minutes to update the cache. More info about the Laravel scheduler
To retrieve all posts use the facade : (this is limited to the latests)
LaravelInstagram::getPosts()
You can specify a number of post to get, it will get the most recents ones :
LaravelInstagram::getPosts(4)
This returns a collection with all the posts stored.
On each post, you can get attributes:
// Full Size Image $post->standardResolutionImageUrl // Caption text $post->captionText // HTML formatted caption text (use {!! !!} to escape <br> tags) $post->htmlCaptionText // Link to the post $post->link
Credits
License
The MIT License (MIT). Please see License File for more information.