Download the PHP package chill-pills/laravel-instagram-basic-feed without Composer
On this page you can find all versions of the php package chill-pills/laravel-instagram-basic-feed. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chill-pills/laravel-instagram-basic-feed
More information about chill-pills/laravel-instagram-basic-feed
Files in chill-pills/laravel-instagram-basic-feed
Package laravel-instagram-basic-feed
Short Description Laravel package that connect to Instagram's new API Basic Display. Retrieve personal user's posts and keep them in cache, with specific commands or with Scheduler and take care to refresh the token's every two months.
License MIT
Informations about the package laravel-instagram-basic-feed
Laravel Instagram Basic Feed
Laravel package connecting to Instagram's new API Basic Display. Retrieving personal user's posts and keep them in cache, with specific commands or with Scheduler, and taking charge of refreshing the Instagram token every two months.
Get started
To use the Instagram Basic Display API, you will need to register a Facebook app and configure Instagram Basic Display. Follow the getting started guide.
Requirements
- PHP 7 or higher
- cURL
- Facebook Developer Account
- Facebook App
Installation
Install the package in your application by running
Add and complete these lines in your .env file
For the INSTAGRAM_VALID_OAUTH_URI
entry, you will use the same URI you used in the Valid OAuth Redirect URIs field when you created the Instagram App. We will retrieve the INSTAGRAM_ACCESS_TOKEN
in the next steps. (Ensure all the other env entries are complete)
Set Up
We will need to go over the following steps to ensure our package is configure to work correctly;
- Permit your App to access your Instagram account’s profile and media
- Retrieve the Authorization code that from the URL
- Use the authorization code to obtain a short-lived API token
- Exchange the short-lived API token for a long-lived API token
Permit your App to access your Instagram account’s profile and media
We need to generate a link which redirects the user to the Instagram “Authorization Window". You can generate the url by running the following command:
Copy & Enter the url in your browser (Your authorization window link should look something like this)
Next, you will be shown the Authorization Window
Click on Authorize
Retrieve the Authorization code that from the URL
You will be redirected to the INSTAGRAM_VALID_OAUTH_URI
. If you look in your browser’s URL bar, you should notice the URL has an authorization code that has been appended to the redirect URL. Something like this:
Copy the authorization code, The authorization code in the redirect URL is everything after code=
up to (but not including) the #_
at the end.
Use the authorization code to obtain a short-lived API token & Exchange the short-lived API token for a long-lived API token
Now with the authorization code we are going to generate access token we can use in our application. Use the command below generate the token. We generate long-lived access_token
because those are valid for 60 days. Replace the authorization_code
with the code from the last step.
Awesome! Now, with this long-lived access_token, you can make requests to the API for the next 60 days. You can also refresh the token, extending for another 60 days as long as the token is not expired and is at least 24 hours old (and has not been revoked by your Instagram user deauthorizing your app).
Usage
There's two commands that lets you fetch your feed or renew the Access Token.
You can add the following scheduler's command to take care of executing those commands automatically
Don't forget to enable the CRON on your machine for Laravel Basic Scheduler in your app/Console/Kernel.php file
To show the Instagram feed on your page, you can just add the following Blade command to include the partial to your page.
You can pass to the @include a hashtag used to search through the posts
If you want to modify the view displaying the instagram posts itself
The MIT License (MIT). Please see License File for more information.
All versions of laravel-instagram-basic-feed with dependencies
illuminate/support Version ^5.8|^6.0|^7.0|^8.0|^9.0
espresso-dev/instagram-basic-display-php Version ^1.1