Get support for ramsey/laravel-oauth2-instagram
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
ramsey/laravel-oauth2-instagram
ramsey/laravel-oauth2-instagram
ramsey/laravel-oauth2-instagram is a Laravel 5 service provider for league/oauth2-instagram.
This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.
Installation
The preferred method of installation is via Composer. Run the following
command to install the package and add it as a requirement to your project's
composer.json
:
composer require ramsey/laravel-oauth2-instagram
After requiring the package with Composer, you'll need to add the following to
the providers
array in config/app.php
:
Ramsey\Laravel\OAuth2\Instagram\InstagramServiceProvider::class
Then, add the following to the aliases
array in the same file:
'Instagram' => Ramsey\Laravel\OAuth2\Instagram\Facades\Instagram::class
Now, run the following to properly set up the package with your Laravel application:
php artisan vendor:publish
Finally, register your application with Instagram
and add your client ID, client secret, and redirect URI to config/instagram.php
.
Examples
Create an authorization URL and redirect users to it in order to request access to their Instagram account:
$authUrl = Instagram::authorize([], function ($url, $provider) use ($request) {
$request->session()->put('instagramState', $provider->getState());
return $url;
});
return redirect()->away($authUrl);
In the route for the redirect URI, check the state and authorization code, and use the code to get an access token. Store the token to the session or to the user's profile in your data store.
if (!$request->has('state') || $request->state !== $request->session()->get('instagramState')) {
abort(400, 'Invalid state');
}
if (!$request->has('code')) {
abort(400, 'Authorization code not available');
}
$token = Instagram::getAccessToken('authorization_code', [
'code' => $request->code,
]);
$request->session()->put('instagramToken', $token);
Use the access token to make authenticated requests to Instagram.
$instagramToken = $request->session()->get('instagramToken');
$instagramUser = Instagram::getResourceOwner($instagramToken);
$name = $instagramUser->getName();
$bio = $instagramUser->getDescription();
$feedRequest = Instagram::getAuthenticatedRequest(
'GET',
'https://api.instagram.com/v1/users/self/feed',
$instagramToken
);
$client = new \GuzzleHttp\Client();
$feedResponse = $client->send($feedRequest);
$instagramFeed = json_decode($feedResponse->getBody()->getContents());
Contributing
Contributions are welcome! Please read CONTRIBUTING for details.
Copyright and License
The ramsey/laravel-oauth2-instagram library is copyright © Ben Ramsey and licensed for use under the MIT License (MIT). Please see LICENSE for more information.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2